Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void execute_cmd(char * args[], int bg){
- /* Relevant für Aufgabe 2 */
- /* clean up children and check if space available */
- if(update_children() >= children_amount){
- printf("Too many processes already running\n");
- return;
- }
- /* TODO Your code here -- Aufgabe 1 */
- int pid = fork();
- if(pid == 0) {
- char** argstemp = &args[1];
- execvp(args[0],argstemp);
- }
- else {
- if(!bg) {
- waitpid(pid, NULL, 0);
- }
- else {
- waitpid(pid,NULL, WNOHANG);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement