Environment variable does not work (especially DARCS_EDITOR)
Simon Marlow
simonmar at microsoft.com
Tue Apr 26 07:56:50 EDT 2005
On 26 April 2005 02:15, Benedikt Schmidt wrote:
> Sorry for taking so long to reply.
>
> On Tue, 2005-04-19 at 11:36 +0100, Simon Marlow wrote:
>> On 16 April 2005 20:41, Benedikt Schmidt wrote:
>>> module Main where
>>> import System.Cmd
>>> main = rawSystem "nvi" []
> [ patch calling resetNonBlockingFD in runProcess ]
>> If we did this, we would also need to re-enable non-blocking mode
>> after the rawSystem completes. Also, this doesn't work well if
>> runProcess is used and the Haskell program continues to run while
>> the subprocess is executing, because the O_NONBLOCK flag is shared
>> between parent and child.
>
> I didn't think about the flags beeing shared between parent and child.
>
> I tried using setFdOption first, but didn't see that rawSystem sets
> stdin back to blocking mode when stdin is evaluated.
>
> This works for me now with ghc-6.4:
> main = do stdin `seq` return ()
> bracket (setFdOption stdInput NonBlockingRead False)
> (\_ -> setFdOption stdInput NonBlockingRead True)
> (\_ -> rawSystem "nvi" [])
>
>
>> So I suggest doing this for System.Cmd.{system,rawSystem} only.
>
> Would something like that be safe for system and rawSystem if all
> arguments where forced before the setFdOption? If there are
> several threads?
You're right, it's not safe in general. Better to leave it up to the
user - your fix is fine. I'll put an entry in the FAQ.
Cheers,
Simon
More information about the Libraries
mailing list