Re: Environment variable does not work (especially DARCS_EDITOR)

[ crossposted to libraries@haskell.org ]
Tommy Pettersson
A likely source of the problem can be that pico aborts if its stdin or stdout isn't a tty. I have that problem with nvi. If you run darcs 1.0.2 you can try and set DARCS_EDITOR to "pico /dev/tty". If you run a later build you may have to write a wrapper script like
#!/bin/sh pico /dev/tty
since the to-be-next stable darcs not always perform the redirection on the system call any longer.
Or, if this turns out to be the problem, and if you know how to make darcs do this redirection of stdin/out in a portable way, fix it in the darcs source.
The problem seems to be related to rawSystem and the ghc RTS (at least GHC 6.4). GHC sets stdin/stdout/stderr to nonblocking mode on startup and nvi doesn't like that. There is a comment in ghc/rts/RtsUtils.c that resetNonBlockingFd is called before exiting because leaving standard file descriptors in nonblocking mode confuses some shells. module Main where import System.Cmd main = rawSystem "nvi" [] The test program works after applying the following patch to GHC that disables nonblocking mode after the fork and before the exec. diff -u -r1.7 runProcess.c --- libraries/base/cbits/runProcess.c 27 Mar 2005 13:41:19 -0000 1.7 +++ libraries/base/cbits/runProcess.c 16 Apr 2005 19:08:52 -0000 @@ -62,6 +62,10 @@ dfl.sa_handler = (void *)quithandler; (void)sigaction(SIGQUIT, &dfl, NULL); } + + resetNonBlockingFd(fdStdInput); + resetNonBlockingFd(fdStdOutput); + resetNonBlockingFd(fdStdError); dup2 (fdStdInput, STDIN_FILENO); dup2 (fdStdOutput, STDOUT_FILENO); I'm not sure how to handle that in darcs without copying/reimplementing the parts of System.Cmd we need. Benedikt
participants (1)
-
Benedikt Schmidt