c popen won’t catch stderr

popen gives you a file handle on a process’ stdout, not its stderr. Its first argument is interpreted as a shell command, so you can do redirections in it:

FILE *p = popen("prog 2>&1", "r");

or, if you don’t want the stdout at all,

FILE *p = popen("prog 2>&1 >/dev/null", "r");

(Any other file besides /dev/null is acceptable as well.)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)