October 08, 2013 potential deadlock spawning process | ||||
---|---|---|---|---|
| ||||
This simple script calls out to find (on a Mac). For me this works. If I increase the output by changing maxdepth to 3 it hangs forever. When I run the same find from the shell it is fine. What could cause a deadlock in this and what is a workaround? http://pastebin.com/ji8dZwAY Thanks Dan |
October 08, 2013 Re: potential deadlock spawning process | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Davidson | On Tuesday, 8 October 2013 at 16:24:50 UTC, Daniel Davidson wrote:
> This simple script calls out to find (on a Mac). For me this works. If I increase the output by changing maxdepth to 3 it hangs forever. When I run the same find from the shell it is fine. What could cause a deadlock in this and what is a workaround?
>
> http://pastebin.com/ji8dZwAY
>
> Thanks
> Dan
I found a workaround with pipeProcess.
auto pipes = pipeProcess(spec, Redirect.stdout | Redirect.stderr);
scope(exit) {
auto exitCode = wait(pipes.pid);
if(exitCode) {
writeln("*** Exited rc(", exitCode, ")");
}
}
foreach (line; pipes.stdout.byLine) writeln(line);
foreach (line; pipes.stderr.byLine)
writeln(text("STDERR| ", line.idup));
}
Thanks,
Dan
|
Copyright © 1999-2021 by the D Language Foundation