Trap signal in child background process

♀尐吖头ヾ 提交于 2019-12-03 05:46:57

The bash manpage on OSX (but it should be the same in other versions) has this to say about signal handling:

Non-builtin commands run by bash have signal handlers set to the values inherited by the shell from its parent. When job control is not in effect, asynchronous commands ignore SIGINT and SIGQUIT in addition to these inherited handlers.

and further on, under the trap command:

Signals ignored upon entry to the shell cannot be trapped or reset.

Since scripts don't use job control by default, this means the case you're talking about.

Reza Toghraee

Per your note:

Signals ignored upon entry to the shell cannot be trapped or reset.

I have noticed that ZSH does not ignore the signals sent back and forth between parent and child process, but bash does. Here's the question I posted myself:

Trapping CHLD signal - ZSH works but ksh/bash/sh don't?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!