Problem with std.process.execvp and redirected stdout.
Steve Teale
steve.teale at britseyeview.com
Mon Jul 30 03:38:30 PDT 2007
The program I am invoking - slave.exe - simply displays its arguments on stdout.
import std.process;
import std.c.stdio;
int main(string[] args)
{
// This compiles and runs. It creates out.txt but the file is
// empty.
string[] pargs = [ "?", "A", "B" ];
freopen("out.txt", "w", stdout);
int rv = execvp("slave.exe", pargs);
return rv;
// If I build the following VC6 program it behaves as expected
// I see the echoed arguments in out.txt
/*
char *pargs[4];
pargs[0] = "?";
pargs[1] = "A";
pargs[2] = "B";
pargs[3] = NULL;
freopen("out.txt", "w", stdout);
execvp("slave.exe", pargs);
return 0;
*/
}
Without the freopen, slave.exe displays the arguments to the console and then hangs - the C program behaves the same way in that case.
I tried constructing an array of char* arguments explicitly with a terminating null, and then calling std.c.process.execvp, but the behavior is the same.
More information about the Digitalmars-d-bugs
mailing list