Can a Linux process block external signals but accept signals from its own process? -
Can a Linux process block external signals but accept signals from its own process? -
i trying setup linux process, blocks sigterm sent kill command (or other process), allows sigterm sent within (through kill(2) scheme call).
is possible?
here illustration programme wrote, sig_blocks both external , internal signals, doesn't want:
#include <signal.h> #include <unistd.h> #include <stdio.h> int main(int argc, char **argv) { sigset_t sigs; sigemptyset(&sigs); sigaddset(&sigs, sigterm); sigprocmask(sig_block, &sigs, 0); printf("sleeping 30 secs, seek killing me! (pid: %d)\n", getpid()); sleep(30); printf("about phone call kill\n"); kill(getpid(), sigterm); printf("this never happens!\n"); homecoming 1; } the output is:
sleeping 30 secs, seek killing me! (pid: 29416) phone call kill never happens! but should be:
sleeping 30 secs, seek killing me! (pid: 29416) phone call kill because process should killed within through kill(getpid(), sigterm).
not sure if you're after, can set signal handler using sigaction sa_siginfo flag, have sigterm handler phone call _exit if siginfo.si_pid pid
linux process signals
Comments
Post a Comment