Repository navigation
Adopt OpenBSD 8.0 posix_spawn chdir file actions - #389
Open
jakepetroules wants to merge 1 commit into
Open
jakepetroules wants to merge 1 commit into
jakepetroules wants to merge 1 commit into
Conversation
OpenBSD 8.0 added posix_spawn_file_actions_addchdir and addfchdir, which POSIX.1-2024 specifies without the _np suffix. Probe for them with dlsym, preferring the unsuffixed names and falling back to _np on older glibc, Bionic and FreeBSD. OpenBSD has no O_SEARCH or O_PATH, so it cannot open a directory for an fchdir action without requiring read permission. Track the path-based chdir action as its own capability and use it when no descriptor can be opened, so a working directory no longer forces the fallback path on its own. OpenBSD still has no close-all mechanism and no POSIX_SPAWN_SETSID, so it continues to spawn through the fork/exec fallback for now.
jakepetroules
marked this pull request as ready for review
October 29, 2026 06:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
OpenBSD 8.0 added
posix_spawn_file_actions_addchdir(3)andposix_spawn_file_actions_addfchdir(3)(commit, man page). POSIX.1-2024 specifies them without the_npsuffix. This adopts them.Changes
posix_spawn_file_actions_addfchdirandposix_spawn_file_actions_addchdirwithdlsym, preferring the unsuffixed names and falling back to the_npspelling used by older glibc, Bionic and FreeBSD. Darwin is unchanged._subprocess_spawn_addchdir, for the path-based action. OpenBSD has noO_SEARCHorO_PATH, so it cannot open a descriptor forfchdirwithout requiring read permission on the directory, whichchdirdoes not. The path-based action needs no descriptor.requiresFallbackSpawnPathnow only requires the fallback for a working directory when neither thefchdirroute nor the path-based action is available.resolveWorkingDirectoryopens a descriptor only when thefchdirroute is usable. Otherwise it does the existing advisory stat/faccessatcheck, which keeps a bad directory from being reported asexecutableNotFound.Behavior on OpenBSD
OpenBSD still has no close-all mechanism (no
POSIX_SPAWN_CLOEXEC_DEFAULT, no closefrom action) and noPOSIX_SPAWN_SETSID, so rule 2 still sends every OpenBSD spawn through the fork/exec fallback. This change corrects capability reporting and removes the working-directory blocker, but does not change runtime behavior there yet.