On Saturday, 10 November 2018 at 15:05:38 UTC, helxi wrote:
Hi. I have not done any multi-threaded programming before. What
I basically want is to read into the output of a long
shellExecute function each second.
In details, I am calling shellExecute("pkexec dd
if=/path/to/file of=/dev/sdx status=progress && sync");
It's a long running process and dd command prints how many
bytes it has written in stdout continuously. I want to read and
parse this output each second. How should I proceed?
shellExecute won't work, because it waits for the process to end
before moving on.
I believe https://dlang.org/phobos/std_process.html#pipeProcess
should do what you want. It returns a ProcessPipes object which
has stdout, from which you should be able to read.