Mail Archives: djgpp-workers/1999/03/01/04:51:03
On Sun, 28 Feb 1999, Alain Magloire wrote:
> dup2(fdmap[0], FILENO_STDIN);
> dup2(fdmap[1], FILENO_STDOUT);
> dup2(fdmap[2], FILENO_STDERR);
> pid = spawn(P_NOWAIT, "start", "/m", path, NULL);
Well, that's just it: the program run by "start /m" doesn't inherit
the standard handles from the parent program. "start" creates a new
virtual machine and runs the program inside it, but it doesn't pass it
the file handle redirection and the environment of the program which
called "start".
So you will need to do something like this:
system ("start.exe /m redir -i input -o output -e error foo.exe");
("redir" is a standard program that comes with DJGPP.)
This still has some problems, like passing the environment variables
(we could change "redir" to read them from a file), and the
redirection will not work in certain cases, like when the parent and
the child try to write to the same file, because Windows generally
prevents two programs from writing to the same file.
- Raw text -