System.Process bugs on Unix

John Goerzen jgoerzen at complete.org
Thu Mar 29 06:52:53 EDT 2007


On Thu, Mar 29, 2007 at 10:55:43AM +0100, Simon Marlow wrote:
> Bryan O'Sullivan wrote:
> >John Goerzen wrote:
> >>
> >>And strace shows that, sure enough, read(0,...) in grep is getting
> >>EAGAIN.
> >>
> >>Sounds like somebody forgot to take the fd out of non-blocking mode.
> >
> >Yep, that looks like what's happening.  See 
> >System/Process/Internals.hs:runProcessPosix.  I wonder why the 
> >lower-level runProcess that it calls is written in C.
> 
> We can't just take a file descriptor out of non-blocking mode, because due 
> to broken POSIX semantics that would screw up GHC's use of the file 
> descriptor (there's no way to set non-blocking mode per-FD).  We can "fix" 

See fcntl(2) -- F_SETFL can change the O_NONBLOCK flag.  I don't think
this should be a problem for the RTS since it can be done only on the
endpoint of the pipe that is used post-fork.

-- John


More information about the Libraries mailing list