1、在子进程中写入数据,在父进程中读取数据
code:
结果:
now, write data to the pipe
the data I wrote is:Jason's messag
now read data from pipe
the data from pipe is Jason's messag
2、使用dup2函数,将标准输出重定向到某文件
code:
结果:
root@ubuntu:/code/chap8# ./run2 doc3
root@ubuntu:/code/chap8# cat doc3
this is Jason
3、实现 who|sort 命令
code:
结果:
root@ubuntu:/code/chap8# ./run3
root pts/1 2010-11-23 11:58 (:0.0)
root pts/2 2010-11-23 13:50 (:0.0)
root tty7 2010-11-23 11:49 (:0)