开发者

dup2 to redirect stdout and stderr to another file descriptor

开发者 https://www.devze.com 2023-02-20 05:42 出处:网络
i havea call like this. int fd[2]; pipe(fd) 开发者_StackOverflow and then dup2(fd[WRITE],STDOUT_FILENO)

i have a call like this.

int fd[2];
pipe(fd)
开发者_StackOverflow

and then

dup2(fd[WRITE],STDOUT_FILENO)

is there a way to use the dup call to duplicate both 1 and 2 to fd[WRITE]?


Just repeat this operation for stderr.

dup2(fd[WRITE], STDOUT_FILENO);
dup2(fd[WRITE], STDERR_FILENO);
0

精彩评论

暂无评论...
验证码 换一张
取 消