Created
March 1, 2017 14:23
-
-
Save kovacshuni/2152491dd1575f943eefcec15b789b40 to your computer and use it in GitHub Desktop.
kill-daemon-process-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
int main(int argc, char **argv) { | |
printf("Hello from the parent process!\n"); | |
pid_t pid = fork(); | |
if (pid == -1) { | |
perror("fork failed"); | |
exit(-1); | |
} else if (pid == 0) { | |
printf("Hello from the child process! Going to sleep...\n"); | |
sleep(60); | |
_exit(0); | |
} else { | |
sleep(10); | |
// printf("Waiting for the child process to terminate...\n"); | |
// int status; | |
// waitpid(pid, &status, 0); | |
printf("The wait is over. Bye.\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment