Skip to content

Instantly share code, notes, and snippets.

@lilydjwg
Created March 13, 2015 04:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lilydjwg/0bfa6807b88e6d39a995 to your computer and use it in GitHub Desktop.
Save lilydjwg/0bfa6807b88e6d39a995 to your computer and use it in GitHub Desktop.
zsh/subreap module
#include<sys/prctl.h>
#include "subreap.mdh"
#include "subreap.pro"
/**/
static int
bin_subreap(char *nam, char **args, Options ops, UNUSED(int func))
{
int reaping = !OPT_ISSET(ops, 'u');
int result = prctl(PR_SET_CHILD_SUBREAPER, reaping);
return result;
}
/*
* boot_ is executed when the module is loaded.
*/
static struct builtin bintab[] = {
BUILTIN("subreap", 0, bin_subreap, 0, -1, 0, "u", NULL),
};
static struct features module_features = {
bintab, sizeof(bintab)/sizeof(*bintab),
0
};
/**/
int
setup_(UNUSED(Module m))
{
return 0;
}
/**/
int
features_(Module m, char ***features)
{
*features = featuresarray(m, &module_features);
return 0;
}
/**/
int
enables_(Module m, int **enables)
{
return handlefeatures(m, &module_features, enables);
}
/**/
int
boot_(Module m)
{
return 0;
}
/**/
int
cleanup_(Module m)
{
return setfeatureenables(m, &module_features, NULL);
}
/**/
int
finish_(UNUSED(Module m))
{
return 0;
}
name=zsh/subreap
link=dynamic
load=no
autofeatures="b:subreap"
objects="subreap.o"
@lilydjwg
Copy link
Author

Put them in zsh source's Src/Modules directory and then build.

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