简体   繁体   中英

sharing vs inheriting signal handlers on linux

vfork man pages say that "Signal handlers are inherited, but not shared."

Suddenly I have lot of confusion regarding what is the meaning of sharing signal handlers and what is meant by inheriting signal handlers.

What I know is that when we create a new process via fork(), the child process has the same signal handlers installed until the child specifies its own handlers for some of the signals or does not call exec(). In case of threads, because the process remains the same, and a signal is sent to a process so it is the process that receives the signal as a whole (though I am not explicitly sure what happens for a multi-threaded process).

But still I want to understand the difference between sharing signal handlers vs inheriting signal handlers

Signal handlers are inherited.

This means the children inherit the same handlers as the parent has.

Signal handlers are not shared.

Calling the parent's handlers is not the same as calling a child's handlers. As the man page says, the signal is delivered to the parent after it is delivered to the children: hence different calls.

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