From: simonmar Date: Tue, 26 Apr 2005 12:00:48 +0000 (+0000) Subject: [project @ 2005-04-26 12:00:48 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~670 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=23951581ee55f8e9ec8d872fa8fb00b54fca7c75;p=ghc-hetmet.git [project @ 2005-04-26 12:00:48 by simonmar] Add entry about non-blocking stdin and System.Cmd.{system,rawSystem}. --- diff --git a/ghc/docs/users_guide/faq.xml b/ghc/docs/users_guide/faq.xml index 011a735..d2d05d7 100644 --- a/ghc/docs/users_guide/faq.xml +++ b/ghc/docs/users_guide/faq.xml @@ -482,6 +482,31 @@ GHCi runtime linker: fatal error: I found a duplicate definition for symbol the option to ld. + + + GHC puts stdin and stdout in + non-blocking mode, which causes problems when I try to invoke a text + editor (for example) using System.Cmd.system or + System.Cmd.rawSystem. + + + The real problem is that Unix shares the non-blocking flag + between all processes accessing a file or stream. It's impossible to + set this flag locally to a single process. GHC's I/O library needs + non-blocking mode to properly support multithreaded I/O. + + Here's one possible fix, if you know that your program isn't + going to be accessing stdin from another thread + while the sub-process is running: + + +> main = do stdin `seq` return () +> bracket (setFdOption stdInput NonBlockingRead False) +> (\_ -> setFdOption stdInput NonBlockingRead True) +> (\_ -> rawSystem "nvi" []) + + +