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

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

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