Skip to content

Instantly share code, notes, and snippets.

@lilydjwg
Created February 14, 2014 12:34
Show Gist options
  • Save lilydjwg/9000254 to your computer and use it in GitHub Desktop.
Save lilydjwg/9000254 to your computer and use it in GitHub Desktop.
make processes reap their own children processes
#include<stdio.h>
#include<sys/prctl.h>
__attribute__ ((constructor)) static void setup(void) {
if(prctl(PR_SET_CHILD_SUBREAPER, 1) != 0){
perror("prctl");
}
}
@lilydjwg
Copy link
Author

gcc -shared -fPIC -o libsubreap.so libsubreap.c then try export LD_PRELOAD=./libsubreap.so.
Linux 3.4+ only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment