[Haskell-cafe] runInteractiveCommand and command not found

Ketil Malde ketil at ii.uib.no
Sat Jul 7 05:27:05 EDT 2007


I notice that when I try to execute a non-existing command with
runInteractiveProcess, nasty things happen when I close the input.  To
be exact, the whole program terminates.  Is this the intended behavior,
and if so, what is the correct way to work around it?

Sample sessions below, "cat" is a valid executable, while "asdf" is not.

-k

% ghci                           
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
Prelude> :m + System.IO
Prelude System.IO> :m + System.Process
Prelude System.IO System.Process> (i,o,e,p) <- runInteractiveCommand "asdf"
Prelude System.IO System.Process> hPutStr i "foo"
Prelude System.IO System.Process> hClose i

% ghci       
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
Prelude> :m + System.Process
Prelude System.Process> :m + System.IO
Prelude System.Process System.IO> (i,o,e,p) <- runInteractiveCommand "cat"
Prelude System.Process System.IO> hPutStr i "foo"
Prelude System.Process System.IO> hClose i
Prelude System.Process System.IO> 
Prelude System.Process System.IO> x<- waitForProcess p
ExitSuccess




More information about the Haskell-Cafe mailing list