#1593: runInteractiveProcess misbehaves when it gets invalid (eg. non-existent)
working directory parameter
---------------------------------------+------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: simonmar
Type: bug | Status: closed
Priority: high | Milestone: 6.8.1
Component: libraries/process | Version: 6.7
Severity: normal | Resolution: fixed
Keywords: | Difficulty: Unknown
Testcase: process004 | Architecture: Unknown
Os: Unknown |
---------------------------------------+------------------------------------
Comment (by wferi):
Just some thoughts. On Posix systems, you could do something like this, if
you can spare a file descriptor:
{{{
int parentCWD;
if (workingDirectory) {
parentCWD = dirfd (opendir ("."));
if (chdir (workingDirectory)) < 0) {
return -1; /* raise the proper exception to the caller */
}
switch (pid = fork ())
{
...
case 0:
{
pPrPr_disableITimers();
/* leave out the directory bussiness here */
/* the child */
if (environment) {
execvpe(args[0], args, environment);
} else {
execvp(args[0], args);
}
}
_exit(127);
default:
if (workingDirectory) {
if (fchdir (parentCWD)) {
/* this can hardly fail, but if it does, throw an exception */
close (parentCWD);
return -1;
}
close (parentCWD);
}
...
}
}}}
I've got no idea about Windows.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1593#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs