CVS commit: src/bin/sh
"Robert Elz" <[email protected]>
| Newsgroups | gmane.os.netbsd.devel.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module Name: src Committed By: kre Date: Wed May 20 00:50:00 UTC 2026 Modified Files: src/bin/sh: eval.c eval.h trap.c Log Message: PR bin/60275 discard some arriving signals The PR is only peripherally relevant to this, but it is all much the same problem, over a fork() trapped signals are maintained, and sh does not really want that. In this case, when there is a vfork() a signal arriving for a child (whether or not it should arrive and be processed) can be treated as if it arrived for the parent, and cause a trap action to be executed by the parent. (Never observed to have happened, as best I am aware, but certainly looks as if it could.) Avoid that, by making sure that the child process never records a signal as having occurred, when it is being a vfork child (while the parent is sharing memory with it). Doing this meant making one variable that was previously local to eval.c globally visible (exposing it in eval.h), and then because the same name is used as a parameter in many other functions, changing the actual variable name (just to avoid potential compiler "shadowing" warnings) - which amounts to most of the actual change here. Then, make sure that variable is only ever set in the parent while signals are blocked (for the actual fix for this PR), so the parent in a signal handler will never see it set. In the signal handler, treat that variable, if set, as indicating that the child should not have received the signal (it should have been, and will be soon, reset to SIG_DFL) and continue to treat it as in the previous fix. Under no circumstances record it as having been received, or the memory shared with the parent will cause the parent to later detect the signal as having been sent to it. Comments added explaining things where appropriate. To generate a diff of this commit: cvs rdiff -u -r1.198 -r1.199 src/bin/sh/eval.c cvs rdiff -u -r1.24 -r1.25 src/bin/sh/eval.h cvs rdiff -u -r1.60 -r1.61 src/bin/sh/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.