Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
September 13, 2015 [D Cookbook]about "Communicating with external processes" part. | ||||
---|---|---|---|---|
| ||||
Hello. :) I just got a this problem when i read "D Cookbook". [ pipe.d ]: ====================================================================== import std.process; import std.stdio; void main(){ auto info = pipeProcess("child.exe"); scope(exit) wait(info.pid); info.stdin.writeln("data to send to the process"); info.stdin.close(); foreach(line; stdout.byLine){ writeln("Received ", line, " from child."); } } ====================================================================== [ child.d ]: ====================================================================== import std.stdio; void main(){ writeln("hello"); } ====================================================================== [ CMD ]: ====================================================================== C:\Users\user\Desktop\pipe>pipe.exe std.stdio.StdioException@std\stdio.d(3867 ---------------- 0x00407BEF 0x00403149 0x004029F0 0x0040289B 0x0040307F 0x00403032 0x0040300E 0x00402FC1 0x0040272F 0x004026DB 0x004020E2 0x00406412 0x004063E7 0x004062FB 0x00403E7F 0x7493336A in BaseThreadInitThunk 0x76EF9882 in RtlInitializeExceptionChain 0x76EF9855 in RtlInitializeExceptionChain Failed to flush stdout: No error ====================================================================== Well... That's all! It's my mistake? How can i slove this problem? :/ regards, |
September 13, 2015 Re: [D Cookbook]about "Communicating with external processes" part. | ||||
---|---|---|---|---|
| ||||
Posted in reply to xky | I'm in a super rush, running late to something else, but try using readln in the child before writing and see what happens. You sent data to it but the child never read it. |
September 13, 2015 Re: [D Cookbook]about "Communicating with external processes" part. | ||||
---|---|---|---|---|
| ||||
Posted in reply to xky | On Sunday 13 September 2015 15:32, xky wrote: > [ pipe.d ]: > ====================================================================== > import std.process; > import std.stdio; > > void main(){ > auto info = pipeProcess("child.exe"); > scope(exit) wait(info.pid); > > info.stdin.writeln("data to send to the process"); > info.stdin.close(); > > foreach(line; stdout.byLine){ I think it should be `info.stdout.byLine` here. > writeln("Received ", line, " from child."); > } > } > ====================================================================== |
September 13, 2015 Re: [D Cookbook]about "Communicating with external processes" part. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Sunday, 13 September 2015 at 13:34:18 UTC, Adam D. Ruppe wrote: > I'm in a super rush, running late to something else, but try using readln in the child before writing and see what happens. You sent data to it but the child never read it. oh my... you're right. lol so, i fix "pipe.d" this: [ pipe.d ] ============================================================ import std.process; import std.stdio; void main(){ auto info = pipeProcess("child.exe"); scope(exit) wait(info.pid); //info.stdin.writeln("data to send to the process"); foreach(line; info.stdout.byLine){ writeln("Result:", line); } } ============================================================ [ CMD ] ============================================================ C:\Users\user\Desktop\pipe>pipe Result:hello ============================================================ work fine. thx so much. :) |
September 13, 2015 Re: [D Cookbook]about "Communicating with external processes" part. | ||||
---|---|---|---|---|
| ||||
Posted in reply to anonymous | On Sunday, 13 September 2015 at 13:44:06 UTC, anonymous wrote:
> On Sunday 13 September 2015 15:32, xky wrote:
>
>> [ pipe.d ]:
>> ======================================================================
>> import std.process;
>> import std.stdio;
>>
>> void main(){
>> auto info = pipeProcess("child.exe");
>> scope(exit) wait(info.pid);
>>
>> info.stdin.writeln("data to send to the process");
>> info.stdin.close();
>>
>> foreach(line; stdout.byLine){
>
> I think it should be `info.stdout.byLine` here.
>
>> writeln("Received ", line, " from child.");
>> }
>> }
>> ======================================================================
Yes, thanks for the tip detail!
|
Copyright © 1999-2021 by the D Language Foundation