Skip to content

Instantly share code, notes, and snippets.

@kovacshuni
Created March 1, 2017 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kovacshuni/2152491dd1575f943eefcec15b789b40 to your computer and use it in GitHub Desktop.
Save kovacshuni/2152491dd1575f943eefcec15b789b40 to your computer and use it in GitHub Desktop.
kill-daemon-process-test
#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