How would I retrieve the stdout error message of a system/shell command?

Justin Whear justin at economicmodeling.com
Thu Sep 8 10:26:10 PDT 2011


The Posix solution is to use pipes. Basically, you'll want the parent 
process to set up a pipe for stderr, fork, then the child process uses the 
write end of the stderr while the parent reads from the other end. Not sure 
what the Windoze solution is.
Alternatively, the cheap and easy way is to use redirects:

system("dmd bla.d 2>error.log");

If an error is thrown, read from error.log.


More information about the Digitalmars-d-learn mailing list