Skip to content

configure: Ensure that posix_spawnp reports ENOENT correctly #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 9, 2022

Conversation

bgamari
Copy link
Contributor

@bgamari bgamari commented Feb 8, 2022

It turns out that POSIX allows implementations to report
errors "lazily" by exiting the spawned process with code 127.

In particular, OpenBSD's implementation returns successfully if the
requested executable doesn't exist. This severely hampers our ability to
report errors accurately.

In this patch we add a configure test for sensible error-reporting
from posix_spawnp and disable it if the test fails.

Fixes #224.

It turns out that POSIX allows implementations to report
errors "lazily" by exiting the spawned process with code 127.

In particular, OpenBSD's implementation returns successfully if the
requested executable doesn't exist. This severely hampers our ability to
report errors accurately.

In this patch we add a `configure` test for sensible error-reporting
from `posix_spawnp` and disable it if the test fails.

Fixes haskell#224.
@bgamari
Copy link
Contributor Author

bgamari commented Feb 8, 2022

@blackgnezdo, could you possibly test this?

@blackgnezdo
Copy link
Contributor

@blackgnezdo, could you possibly test this?

I'd be happy to. Is there a better way than plugging this into a full ghc build? I remember having trouble building process on the side and using it in ghci.

@blackgnezdo
Copy link
Contributor

blackgnezdo commented Feb 9, 2022

Here's the result after running autoconf

$ cabal v2-test
Warning: The package list for 'hackage.haskell.org' is 19 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Build profile: -w ghc-8.10.6 -O1
In order, the following will be built (use -v for more details):
 - process-1.6.14.0 (first run)
Configuring process-1.6.14.0...
configure: WARNING: unrecognized options: --with-compiler
checking for gcc... /usr/bin/cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether /usr/bin/cc accepts -g... yes
checking for /usr/bin/cc option to enable C11 features... none needed
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for vfork.h... no
checking for pid_t... yes
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for signal.h... yes
checking for sys/wait.h... yes
checking for fcntl.h... yes
checking for setitimer... yes
checking for sysconf... yes
checking for execvpe... yes
checking for spawn.h... yes
checking for posix_spawnp... yes
checking for posix_spawn_file_actions_addchdir... no
checking for /usr/bin/cc options needed to detect all undeclared functions... -fno-builtin
checking whether POSIX_SPAWN_SETSID is declared... no
checking whether POSIX_SPAWN_SETSID_NP is declared... no
checking whether POSIX_SPAWN_SETPGROUP is declared... yes
checking whether posix_spawn reports errors sensibly... no, falling back to fork/exec
checking value of SIG_DFL... -1
checking value of SIG_IGN... -1
configure: creating ./config.status
config.status: creating include/HsProcessConfig.h
configure: WARNING: unrecognized options: --with-compiler
Preprocessing library for process-1.6.14.0..
Building library for process-1.6.14.0..
[1 of 5] Compiling System.Process.Common ( System/Process/Common.hs, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/System/Process/Common.o, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/System/Process/Common.dyn_o )
[2 of 5] Compiling System.Process.Posix ( System/Process/Posix.hs, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/System/Process/Posix.o, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/System/Process/Posix.dyn_o )
[3 of 5] Compiling System.Process.Internals ( System/Process/Internals.hs, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/System/Process/Internals.o, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/System/Process/Internals.dyn_o )
[4 of 5] Compiling System.Process   ( System/Process.hs, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/System/Process.o, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/System/Process.dyn_o )
[5 of 5] Compiling System.Cmd       ( System/Cmd.hs, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/System/Cmd.o, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/System/Cmd.dyn_o )
Preprocessing test suite 'test' for process-1.6.14.0..
Building test suite 'test' for process-1.6.14.0..
[1 of 1] Compiling Main             ( test/main.hs, /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/test/test-tmp/Main.o )
Linking /home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/build/test/test ...
Running 1 test suites...
Test suite test: RUNNING...
Test suite test: PASS
Test suite logged to:
/home/greg/s/ghc/libraries/process/dist-newstyle/build/x86_64-openbsd/ghc-8.10.6/process-1.6.14.0/test/process-1.6.14.0-test.log
1 of 1 test suites (1 of 1 test cases) passed.

@blackgnezdo
Copy link
Contributor

Works great for me on -current OpenBSD.

@snoyberg snoyberg merged commit 1e142ab into haskell:master Feb 9, 2022
@bgamari
Copy link
Contributor Author

bgamari commented Feb 14, 2022

It would be great to get a new process release out with the recent fixes.

@snoyberg
Copy link
Collaborator

Sure, I'll do that now, I just wanted to wait on #225.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some diagnostics from do_spawn_posix are very terse
3 participants