I want to run another program from c++, redirecting its output to a file and return its result code. But if I fail to run the program (incorrect path etc.) I want to know.
Here is my problem, how can I: redirect a file, get the result code of the program, get the errors of the system, all at once?
System()
: returns the result and is easy to redirect, but there is no way to know if the result is a system error or the application resultposix_spawn()
: I know if there is a system error, but how to get the application result code ?
Note that I don't control the code of the executed application
It's easy with Windows (sorry...) OpenProcess()
function, what I need is OpenProcess()
under linux.
Thanks