[APUE] dup 的小测试

#include 
#include 
#include 
#include 

int main()
{
    char a[10] = "std in\n";
    char b[10] = "std out\n";
    char c[10] = "std error\n";

    write(0, a, sizeof(a));
    write(1, b, sizeof(b));
    write(2, c, sizeof(c));
    return 0;
}

mattchen@ooxx:~/code/dup$ ./a.out 
std in
std out
std error
mattchen@ooxx:~/code/dup$ ./a.out 2>&1
std in
std out
std error
mattchen@ooxx:~/code/dup$ ./a.out 2>&1 >tmpfile
std in
std error
mattchen@ooxx:~/code/dup$ ./a.out >tmpfile 2>&1 
std in
此条目发表在C, Linux, 系统, 编程分类目录,贴了, , 标签。将固定链接加入收藏夹。

发表评论

邮箱地址不会被公开。 必填项已用*标注