arun11299 / cpp-subprocess

Subprocessing with modern C++
Other
456 stars 90 forks source link

example to get stdout and stderr while process is running #26

Closed lunu-bounir closed 5 years ago

lunu-bounir commented 5 years ago

Hello,

Can we have an example to get outputs of the child process in a loop while the child process is still alive. Consider that the child is going to run for a while. Also I need to terminate the child when the parent process is being killed. Is it possible?

bdangit commented 5 years ago

Here is an example of a child process running the background. https://github.com/arun11299/cpp-subprocess/blob/master/test/test_subprocess.cc#L42-L52

Since you have the process object, you should be able to fetch the stdout and stderr, similiar to this example: https://github.com/arun11299/cpp-subprocess/blob/master/test/test_subprocess.cc#L67-L73

lunu-bounir commented 5 years ago

Thanks @bdangit