Skip to content

Instantly share code, notes, and snippets.

@thegabriele97
Last active December 28, 2018 20:21
Show Gist options
  • Save thegabriele97/856c02c98035b089d3f48d30d30ad9e4 to your computer and use it in GitHub Desktop.
Save thegabriele97/856c02c98035b089d3f48d30d30ad9e4 to your computer and use it in GitHub Desktop.
#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