Skip to content

Instantly share code, notes, and snippets.

@mepcotterell
Created February 5, 2019 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mepcotterell/0b97227e50fadcdf57b2631d84cebc5d to your computer and use it in GitHub Desktop.
Save mepcotterell/0b97227e50fadcdf57b2631d84cebc5d to your computer and use it in GitHub Desktop.

main.c

#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>

int main() {
  pid_t pid = fork();
  if (pid == 0) {
    for(;;);
  } // if

  int status;
  wait(&status);

  if (WIFSIGNALED(status)) {
    printf("child died from signal\n");
  } // if
  
  return 0;
} // main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment