Created
May 29, 2013 00:05
-
-
Save Lerc/5667065 to your computer and use it in GitHub Desktop.
An idea for http://omg2.thedailywtf.com/
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 <unistd.h> | |
#include <stdlib.h> | |
#include <signal.h> | |
#include <stdio.h> | |
void sig_handler(int sig) {exit(0);}; | |
int main () { | |
signal(SIGTERM,sig_handler); | |
pid_t pid_v; | |
char* result = "heads\0tails"; | |
pid_v=fork(); | |
if(!pid_v) { | |
pid_v=getppid(); | |
result+=6; | |
} | |
srandom(pid_v); | |
usleep(random() &0xffff); | |
kill(pid_v,SIGTERM); | |
puts(result); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment