1

Bash manual says

When a simple command other than a builtin or shell function is to be executed, ... traps caught by the shell are reset to the values inherited from the shell’s parent, and traps ignored by the shell are ignored

execve() manpage says

During an execve(2), the dispositions of handled signals are reset to the default; the dispositions of ignored signals are left unchanged."

Are "the default" and "the values inherited from the shell’s parent" the same?

Does bash calls execve() without making further change to how execve() treats the signal dispositions?

Thanks.

2

No, "the default" and "the values inherited from the shell’s parent" are not the same. In execve's case, "the default" refers to SIG_DFL, which causes the default action as specified by man 7 signal. In bash's case, "the values inherited from the shell’s parent" means exactly what it says; if such a signal was ignored (SIG_IGN) by its parent, it will be ignored in its child too.

A key to understanding what's going on here is the word "handled". It refers to a custom signal handler function, distinct from either SIG_DFL or SIG_IGN. It must be reset by execve, as the new process won't have the signal handler function that the old process used.

Note that newer versions of the execve manpage refer to the "handled" signals as "caught" signals, to be in line with the terminology used by the rest of Linux. This is still distinct from both default and ignored signals.

Simple version: if either bash or bash's parent had a signal marked as SIG_IGN, it will be SIG_IGN in the new child too. Otherwise, it will be SIG_DFL in the new child. It can never be a handler in the new child, since no handler from bash or its parent will exist in the new child.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.