threads / discuss / 57665

ignored signals are not reset on execve

Subject: ignored signals are not reset on execve

## tl;dr

One message between Apr 5, 2022 and Apr 5, 2022.

replies: 0people: 1as markdown or json

Rasmus Villemoes· Apr 5, 2022, 09:08 UTC · lore
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

← back to recent threads