NetBSD-Bugs archive

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

Re: bin/60275: sh(1): race condition in signal handling on background subshell fork



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

From: Christos Zoulas <christos%zoulas.com@localhost>
To: Robert Elz <kre%munnari.oz.au@localhost>
Cc: gnats-bugs%netbsd.org@localhost,
 netbsd-bugs%netbsd.org@localhost
Subject: Re: bin/60275: sh(1): race condition in signal handling on background
 subshell fork
Date: Tue, 19 May 2026 17:16:38 -0400

 --Apple-Mail=_71CA3235-A297-43B0-88A0-D2D95E0D2FAE
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=utf-8
 
 
 
 > On May 19, 2026, at 4:31=E2=80=AFPM, Robert Elz <kre%munnari.oz.au@localhost> =
 wrote:
 >=20
 >    Date:        Tue, 19 May 2026 14:30:10 -0400
 >    From:        Christos Zoulas <christos%zoulas.com@localhost>
 >    Message-ID:  <645CF0B9-1ADB-4DFC-B5BC-E9844896BC1F%zoulas.com@localhost>
 >=20
 >=20
 >  | vfork() is temperamental.
 >=20
 > Yes, I know.   Perhaps fortunately, at the minute, our shell doesn't
 > even really pretend to build outside NetBSD, so some of the issues =
 aren't
 > relevant (something on my list to perhaps work on, if I ever find the =
 time).
 >=20
 >  | In some implementations the signal disposition is shared
 >  | between parent and the vforked() child.
 >=20
 > Which is what I am dealing with at the minute ... if that isn't true =
 of
 > NetBSD, then I have been (today) wasting some time - as I said, I =
 can't
 > think of a good way to test this new issue (vfork() only problem).
 >=20
 > What would help all of this, the issue Taylor found, and this variant
 > related problem, would be if sigaction() had a SA_RESETFORK flag, to
 > cause the signal in question to be reset to the default (SIG_DFL) in =
 the
 > child after a fork() (including vfork()).   Want to add that?   All =
 these
 > issues could be made to simply vanish if that existed.
 >=20
 
 Perhaps it is time to ditch vfork() in sh and use posix_spawn() instead.
 Otherwise the only solution is to block the relevant signals and save =
 the
 signal handlers bebore vfork() and then restore/unblock them once the =
 child is
 done.
 
 christos
 
 
 --Apple-Mail=_71CA3235-A297-43B0-88A0-D2D95E0D2FAE
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP
 
 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - http://gpgtools.org
 
 iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCagzTNgAKCRBxESqxbLM7
 OncYAKDtbqLfgGy1dXQJUrmaK3Q2lsZVKwCfeiCQRIXuk66H7aboNaWtlsNSvu8=
 =37Ju
 -----END PGP SIGNATURE-----
 
 --Apple-Mail=_71CA3235-A297-43B0-88A0-D2D95E0D2FAE--
 



Home | Main Index | Thread Index | Old Index