Process Pipes

Colin grogan.colin at gmail.com
Wed Oct 10 10:20:31 UTC 2018


On Tuesday, 9 October 2018 at 09:15:09 UTC, Gorker wrote:
> Hi all,
>
> I'm on macOS 10.11.6 with dmd 2.081.2 and I've a problem with 
> std.process.
>
> ---
> gork ():foo gorker$ gcc -c -Iinclude -o foo.cpp.o src/foo.cpp
> In file included from src/foo.cpp:2:
> include/foo/foo.hpp:22:10: warning: scoped enumerations are a 
> C++11 extension [-Wc++11-extensions]
>     enum class foo_event_type_t
>          ^
>     <snip, about 14k in STDERR>
>
>     56 warnings and 9 errors generated.
> ---
> No output, (zero bytes) in stdout.
>
> If I use standard process to collect both stream with:
> ---
> auto processPipes = pipeProcess(args, Redirect.all, null, 
> Config.none, workDir);
> foreach (c; pipes.stdout.byChunk(100)) writeln(cast(string) c); 
> // <<<---- it halts here: stdout file is empty, but not EOF
> foreach (c; pipes.stderr.byChunk(100)) writeln(cast(string) c);
> ---
> Everything is fine if I don't redirect the stderr to a pipe.
>
> Suggestions?

If you want to use asynch io - you'll have to fork and use 
NONBLOCK output on the file descriptor.

I wrote this years ago (not sure if it still compiles tbh, but it 
should)

https://github.com/grogancolin/dexpect

Specifically this block should help you: 
https://github.com/grogancolin/dexpect/blob/master/source/dexpect.d#L343-L352


More information about the Digitalmars-d-learn mailing list