Skip to content

Instantly share code, notes, and snippets.

@dragon3
Created November 18, 2009 14:54
Show Gist options
  • Save dragon3/237924 to your computer and use it in GitHub Desktop.
Save dragon3/237924 to your computer and use it in GitHub Desktop.
/*
* 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