03-16-06 10:53 PM
Hi,
I am a little confused with the second one.Lemme explain what I
understand.
Gordon Burditt wrote:
>
>
> filefd = open("file", ...); /* >file */
> dup2(filefd, 1);
> close(filefd);
>
> dup2(1, 2); /* 2>&1 */
Here, stdout is redirected to file,so now file is the stdout.Then stderr
is redirected to stdout,which is also now the file.
>
>
> dup2(1, 2); /* 2>&1 */
>
> filefd = open("file", ...); /* >file */
> dup2(filefd, 1);
> close(filefd);
>
Here,stderr is redirected to stdout.stdout is redirected to file and
hence stdout is file.
Unlike the first case where both the stderr & stdout output goto the
file,in this case stderr goes to stdout and stdout goes to file.
Is the & then really required with the 1(stdout).
Thanks,
~
[ Post a follow-up to this message ]
|