pipeProcess: read stdout and stderror simultaneously

unDEFER via Digitalmars-d digitalmars-d at puremagic.com
Sun Nov 13 09:49:53 PST 2016


Hello!
I'm trying to run rsync and handle errors and operation progress 
at the same time:

================
auto rsync_pipes = pipeProcess(["rsync", "-avu", "--delete", 
path, copy_to], Redirect.stdout | Redirect.stderr);
     scope(exit) wait(df_pipes.pid);

foreach (df_line; df_pipes.stdout.byLine)
{
     //This will read stdout till finishing the process
}

foreach (df_line; df_pipes.stderr.byLine)
{
     //Handle errors when it is already not actual???
}
================

So, I need one of 2 option:
1) Not blocking byLine() to read df_pipes.stdout and 
df_pipes.stderr in the loop like:
while (!ProcessFinished)
{
foreach (df_line; df_pipes.stdout.notBlockingByLine)
{
     //Handle progress
}
foreach (df_line; df_pipes.stderr.notBlockingByLine)
{
     //Handle errors
}
}


More information about the Digitalmars-d mailing list