NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

PR/60275 CVS commit: src/bin/sh



The following reply was made to PR bin/60275; it has been noted by GNATS.

From: "Robert Elz" <kre%netbsd.org@localhost>
To: gnats-bugs%gnats.NetBSD.org@localhost
Cc: 
Subject: PR/60275 CVS commit: src/bin/sh
Date: Mon, 18 May 2026 16:40:00 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Mon May 18 16:40:00 UTC 2026
 
 Modified Files:
 	src/bin/sh: eval.c jobs.c jobs.h trap.c
 
 Log Message:
 PR bin/60275 discard even less arriving signals
 
 Avoid signals arriving immediately after a fork() (or vfork())
 by blocking everything (everything possible) while the fork()
 happens, in the parent, for (close to) the minimum possible time,
 in the child, until it has its state init'd enough that it is
 safe for signals to arrive.
 
 Further, if a signal does arrive (in a child) which was trapped
 in the parent, but hasn't been cleaned up fully yet, instead of
 simply ignoring it, send it to ourselves, after setting its state
 to SIG_DFL (which is what would eventually happen to a trapped
 signal anyway).   If that doesn't kill us, then we will end up
 (harmlessly) setting the state to SIG_DFL again later as would happen
 if the signal hadn't arrived in this short window; we cannot record that
 it happened to avoid that, as we might be in a vforked child, and
 anything recorded by that would be visible back in the parent later
 (where the signal action was not changed).
 
 Always use raise(N) rather than kill(getpid(), N) - just to save an
 unnecessary getpid() sys call.  Of course, the current implementation
 of raise() does much the same (just _lwp_self() rather than getpid())
 but one can imagine a future where raise() was raised to the status of
 being a sys call of its own (it would be a trivial one to implement).
 
 After this change, the previous change to trap.c is probably no longer
 needed (will never be invoked) as the situation which allowed a (parent)
 trapped signal to be received in the child, without immediately being
 ignored by onsig() should no longer be possible (the signal blocking
 should prevent that).   However it is very small, correct if it were to
 be invoked, and harmless otherwise.
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.197 -r1.198 src/bin/sh/eval.c
 cvs rdiff -u -r1.125 -r1.126 src/bin/sh/jobs.c
 cvs rdiff -u -r1.27 -r1.28 src/bin/sh/jobs.h
 cvs rdiff -u -r1.59 -r1.60 src/bin/sh/trap.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.
 



Home | Main Index | Thread Index | Old Index