Specifically on Mac OS X, is it possible to make a program ignore SIGTERM via DYLD_INSERT_LIBRARIES, in a way which works for any or most programs?
I tried compiling and inserting this:
#include<stdio.h>
#include<signal.h>
#include<unistd.h>
void sig_handler(int signo)
{
if (signo == SIGTERM)
printf("received SIGTERM\n");
}
int main(void)
{
signal(SIGTERM, sig_handler);
return 0;
}
However,
DYLD_INSERT_LIBRARIES=libignore.dylib sleep 60
was able to be kill -15'd without issue.
You can create an executable that sets the action for
SIGTERM
toSIG_IGN
and thenexecvp()
the program you would like to run with that signal ignored:You can do that even with bash:
And then: