diff options
author | fadhil riyanto <me@fadev.org> | 2024-09-27 20:06:57 +0700 |
---|---|---|
committer | fadhil riyanto <me@fadev.org> | 2024-09-27 20:06:57 +0700 |
commit | 369b6484db835bf42f84b469a9c03631cfc06c4d (patch) | |
tree | e78e09a7a46da2e2dbb1541ae439edd4ed30201c | |
parent | 544420827e20952df190f84856a2ff82b3b2b16c (diff) |
test fork
Signed-off-by: fadhil riyanto <me@fadev.org>
-rw-r--r-- | test/waitsys.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/waitsys.c b/test/waitsys.c new file mode 100644 index 0000000..9f1534c --- /dev/null +++ b/test/waitsys.c @@ -0,0 +1,25 @@ +#include <signal.h> +#include <stdio.h> +#include <unistd.h> +#include <sys/wait.h> + +int main(void) +{ + pid_t parentpid = getpid(); + + pid_t child_pid = fork(); + + if (child_pid == 0) { + + sleep(10); + printf("child process created\n"); + _exit(0); + } else { + printf("this is parent\n"); + + int status; + wait(&status); + sleep(20); + } + +}
\ No newline at end of file |