-
Notifications
You must be signed in to change notification settings - Fork 89
Description
When running this Haskell code:
import System.Posix.User
import System.Process
getEffectiveGroupID >>= \egid -> createProcess (proc "/nonexistent" []){ std_in = CreatePipe, std_out = CreatePipe, std_err = CreatePipe, child_group = Just egid }The resulting exception will incorrectly be invalid argument (Bad file descriptor) instead of does not exist (No such file or directory). The problem itself has nothing to do with GIDs, but by setting one, do_spawn_fork is forced to be used instead of do_spawn_posix, which makes this reproducible even when posix_spawn is otherwise supported.
The problem is that the parent_end FD of stdin, stdout, and stderr all get closed both by runInteractiveProcess and by do_spawn_fork. In addition to all of the problems that double-close usually causes, here it also causes errno to be unexpectedly overwritten. I'm pretty sure, but not 100% positive, that runInteractiveProcess is the one that's supposed to be closing them, and that do_spawn_fork shouldn't be.