Skip to content

Instantly share code, notes, and snippets.

@jdv85

jdv85/exit.c Secret

Last active May 27, 2021 11:10
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 jdv85/5a67ae81247f21433044b0ffea404693 to your computer and use it in GitHub Desktop.
Save jdv85/5a67ae81247f21433044b0ffea404693 to your computer and use it in GitHub Desktop.
void exitOnParentExit(void) {
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC,
getppid(),
DISPATCH_PROC_EXIT, NULL);
dispatch_source_set_event_handler(source, ^{
exit(0);
});
dispatch_resume(source);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment