c - Redirect STDOUT and STDERR to file ">&" -


i've coded , i'm unsure how work other way. appreciate example code of how test correctness.

thanks help

dup2(stdout_fileno, stderr_fileno); dup2(fd, stdout_fileno); 

you close, need 2 dup2 calls in opposite order.

dup2(fd, stdout_fileno); dup2(stdout_fileno, stderr_fileno); close(fd); 

your code equivalent posix shell syntax (which available in shells syntax based on bourne shell):

2>&1 >filename 

which makes stderr go old stdout while redirecting stdout file.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -