From 65966ded0cc15c5966c6568cf0ff2f2bbe1fc29a Mon Sep 17 00:00:00 2001 From: Stefan Zabka Date: Sun, 24 May 2020 12:09:46 +0200 Subject: Big remodelling --- 02_exercise/beispiele/fork_example/fork.c | 36 ------------------------------- 1 file changed, 36 deletions(-) delete mode 100644 02_exercise/beispiele/fork_example/fork.c (limited to '02_exercise/beispiele/fork_example/fork.c') diff --git a/02_exercise/beispiele/fork_example/fork.c b/02_exercise/beispiele/fork_example/fork.c deleted file mode 100644 index 7377b0f..0000000 --- a/02_exercise/beispiele/fork_example/fork.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include -#include -#include - -int main(void) { - pid_t proc_id; - int status = 0; - - proc_id = fork(); - - if (proc_id < 0) { - fprintf(stderr, "fork error\n"); - fflush(stderr); - return EXIT_FAILURE; - } - - if (proc_id == 0) { - /* child process */ - printf("[child] process id: %d\n", (int) getpid()); - - char* args[] = {"sleep", "1", NULL}; - execvp(args[0], args); - exit(-1); - } - else { - /* parent */ - printf("[parent] process id: %d\n", (int) getpid()); - pid_t child_id = wait(&status); - - printf("[parent] child %d returned: %d\n", - child_id, WEXITSTATUS(status)); - } - - return EXIT_SUCCESS; -} -- cgit v1.2.3-54-g00ecf