Spawning a console in Windows (similar to forkpty on linux)

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 10 01:12:07 PDT 2015


On Saturday, 9 May 2015 at 13:00:01 UTC, wobbles wrote:
> Just as an example of running cmd through std.process, running 
> this on my system:
> 	auto pipes = pipeShell("cmd.exe");
> 	write(pipes.stdout.readln);
> 	write(pipes.stdout.readln);
> 	write(pipes.stdout.readln);
>         return;
> will print
> `
> Microsoft Windows [Version 6.3.9600]
> (c) 2013 Microsoft Corporation. All rights reserved.
>
> `
> and then exits.
>
> However, adding another "write" line before the return; will 
> cause the program to hang there, waiting for the cmd.exe 
> process to flush it's next line.

I guess, the last (prompt) line is properly flushed, it just 
doesn't have EOL, that's why readln won't return it. See if 
stdout has a method to read/peek whatever data it has without 
waiting for EOL.


More information about the Digitalmars-d-learn mailing list