Various assorted improvements to spawnveg #881
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alterations:
spawnveg
. This is the primary cause of a lockup in the pty tests occurring on Linux distributions using glibc 2.35+. The correct way to go about dealing withSIGT*
is to set those toSIG_DFL
in the child process; see_sh_fork()
for a working example that doesn't lock up or produce segfaults. In this commit I duplicate_sh_fork
's behavior inspawnveg
for thefork
fallback and withPOSIX_SPAWN_SETSIGDEF
for theposix_spawn
version. The lockup can be reproduced as follows:tcsetpgrp
to thefork
fallback inspawnveg
. Some form of this appears to have already been attempted in AT&T olden times, but that old version was broken and needed bugfixes desperately.tcsetpgrp
, block the terminal signals in the parent process viasigcritical()
. Theposix_spawn
version doesn't need this becauseposix_spawn
will usually block signals automatically and therefore doesn't needsigcritical
.fork
fallback forspawnveg
works correctly in interactive terminals, prefer that to thesh_fork()
codepath on operating systems withoutposix_spawn_file_actions_addtcsetpgrp_np
. Even though the underlying system call is still ultimatelyfork
, thesh_ntfork()
codepath is faster than the traditionalsh_fork()
codepath. Benchmark (FreeBSD 14.2):spawnveg
versions intospawnveg_fast
andspawnveg_slow
. Choose the appropriate one whenspawnveg
is called; this removes the need for the xec.c ifdef hackery.ntfork_tcpgrp
ifdefs from xec.c;spawnveg
can handle it by itself now.spawnveg_fast
andspawnveg_slow
innovation,spawnveg
now always has support forsetsid
. It'll fallback to fork ifPOSIX_SPAWN_SETSID
isn't available.posix_spawn
version ofspawnveg
, the flags should be of theshort
type pursuant to the POSIX specification.pipe2
in thefork
fallback forspawnveg
when it's available to avoid twofcntl
syscalls.spawnveg
documentation to reflect the new changes.