ignored signals are not reset on execve
- From
- Rasmus Villemoes <rasmus.villemoes@prevas.dk>
- Date
- Apr 5, 2022, 09:08 UTC
- Message-ID
- <420575be-1e0d-2c3b-ca5e-f9084688dcbb@prevas.dk>
Hi,
run-command.c has
for (sig = 1; sig < NSIG; sig++) {
/* ignored signals get reset to SIG_DFL on execve */
if (signal(sig, SIG_DFL) == SIG_IGN)
signal(sig, SIG_IGN);
}introduced by commit 45afb1ca9c28 (run-command: block signals between fork and execve).
However, 'man 7 signal' says
A child created via fork(2) inherits a copy of its parent's
signal dispositions. During an execve(2), the dispositions of
handled signals are reset to the default; the dispositions of
ignored signals are left unchanged.So at least the comment is wrong, and the child is actually run with those signals ignored. Whether that's the intent I cannot say, but I doubt it; programs generally don't expect to be run with any signals ignored.
Rasmus