★实验9-3 1.用不同的方案实现两个命令的连接,例如 “who|sort”、“ps aux | grep init” 源程序: #include <stdio.h> #include <sys

来源:互联网 发布:ubuntu怎么进入文件夹 编辑:程序博客网 时间:2024/05/20 05:29
★实验9-3  1.用不同的方案实现两个命令的连接,例如 “who|sort”、“ps aux | grep init”源程序:#include <stdio.h>#include <sys/types.h>#include <unistd.h>#include <fcntl.h>#include <sys/wait.h>#include <stdlib.h>int main(int argc,char *argv[]){   FILE *fp;   fp=execlp("who","who",(char*)0);   dup2(fp,0);   execlp("sort","sort",(char*)0);   return 0;}

阅读全文
1 0
原创粉丝点击