Posted: 07/14/08 13:25:49
Thanks for the quick replies. Yes, I also suspect
the flushing to be a reason. The child looks like
this:
void
DebugMsg(const char *fmt,...){
char buf[8192];
va_list args;
va_start(args,fmt);
vsnprintf(buf,sizeof(buf),fmt,args);
OutputDebugStringA(buf);
va_end(args);
}
int
main(int argc, char **argv){
char buf[1024];
int i;
fputs("Hello\n", stdout);fflush(stdout);
while(1){
fgets(buf,1024,stdin);
for(i=0; i<1000; i++){
fputs(buf,stdout);
fflush(stdout);
}
DebugMsg("echo: Got %d bytes: {%s}\n",strlen(buf),buf);
if ( buf[0] == 'q')
break;
}
DebugMsg("Exiting");
return 0;
}
Compiled with gcc -mno-cygwin, i.e. MinGW under XP. I can see the DebugMsg? with Dbgview, so
the flow to the child works. The parent looks like this:
int
main(String[] args){
char[] xxx;
int i;
Process p = new Process(ddbgexe);
p.execute();
Stdout.formatln("Process started");
Stdout.flush();
p.stdin.write("Hallo\n");
p.stdin.flush();
Thread.sleep(0.5);
p.stdout.read( xxx );
Stdout.formatln("{}\n", xxx);
p.stdin.write("quit\n");
p.stdin.flush();
/*
p.stdout.read( xxx );
Stdout.formatln("Output from process '{}' (pid {})\n----------", p.programName, p.pid);
Stdout.formatln("{}\n", xxx);
for(i=0; i<100; i++){
p.stdout.read( xxx );
Stdout.formatln("{}\n", xxx);
Thread.sleep(0.1);
}
*/
/*
Stdout.stream.copy(p.stdout);
Stdout("----------").newline;
Stdout.flush();
Stdout.stream.copy(p.stdout);
*/
return 0;
}
dmd.1.028, tango-0.99.6, WinXP. I am doing something fundamentally wrong, but what?
Ciao
Tom
Ciao
Tom