potential deadlock spawning process

Daniel Davidson nospam at spam.com
Tue Oct 8 12:17:46 PDT 2013


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


More information about the Digitalmars-d-learn mailing list