[plt-scheme] subprocess when current-directory is invalid
At Wed, 13 Feb 2008 12:37:50 -0500 (EST), Danny Yoo wrote:
> Given the following program, I get a weird error message:
>
> #lang scheme/base
> (parameterize ([current-directory (build-path "nonexistant-path")])
> (let-values ([(subp stdin stdout stderr)
> (subprocess #f #f #f "/bin/ls")])
> (for ([ch stderr])
> (write-char (integer->char ch)))))
>
> I know that this should fail, but the particular failure is weird:
>
> ###################################################################
> XIO: fatal IO error 9 (Bad file descriptor) on X server ":0.0"
>
> after 494681 requests (494681 known processed) with 0 events
> remaining.
> ###################################################################
In case it's not clear, this is because the process that fails to run a
new program is a fork of the DrScheme process, and there's no X
connection in the forked process. I'm not sure I can fix this, but I'll
investigate more.
> Context: I had run into a bug in a larger program where I constructed a
> bad current-directory, saw the strange output from stderr, and had to
> chase a bit till I figured out the root cause.
>
> Can the erroneous condition, that current-directory not being a real
> directory, be caught by subprocess even before it tries to execute?
Not in principle, since the directory can disappear between any check
and the attempt to use it in the subprocess (i.e., any such check has a
race condition). But a check should work well in practice.
Matthew