简体   繁体   中英

Can a linux parent process protect the child process from a signal?

I have an application (in Java BTW) which forks third-party command-line utilities as child processes. When this application is given a signal such as SIGTERM, I notice that that signal gets forwarded to all child processes as well.

There's a lot of stuff online I can find about how to handle signals within a process, but I have no control over how the third-party tools choose to handle their signals.

Ideally what I'd like to do in my application, is block any incoming signals from cascading down to my children, and handle them myself. From what I've seen, implementing my own signal-handlers doesn't prevent the signal from propagating independently to my children.

If the kill signal is sent to the entire group (using killpg() system call), all processes should receive it.

In order to protect the child, the child either needs to configure a signal handler and/or sigprocmask, or you need to ptrace the child and intercept the signal delivery)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM