Last active
December 28, 2018 20:21
-
-
Save thegabriele97/856c02c98035b089d3f48d30d30ad9e4 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <unistd.h> | |
#include <sys/wait.h> | |
#include <sys/types.h> | |
#include <pthread.h> | |
#include <signal.h> | |
bool waiting = true; | |
void handler(int sig) { | |
printf("Hi, I am beatiful!\n"); | |
waiting = false; | |
fflush(stdout); | |
} | |
int main (int argc, char **argv) { | |
signal(SIGCHLD, handler); | |
if (!fork()) { | |
sleep(1); | |
exit(0); | |
} | |
while(waiting); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment