Created
November 18, 2009 14:54
-
-
Save dragon3/237924 to your computer and use it in GitHub Desktop.
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
/* | |
* TechTouch #0b10001 | |
* | |
* kill parent | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/wait.h> | |
#include <signal.h> | |
int main(int argc, char *argv[]) | |
{ | |
pid_t pid; | |
pid = fork(); | |
if (pid==0) { | |
/* child */ | |
sleep(3); | |
pid_t ppid = getppid(); | |
kill(ppid, SIGKILL); | |
while(1) { | |
} | |
} | |
else { | |
/* parent */ | |
printf("%d\n", pid); | |
sleep(30); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment