当前位置: 技术问答>linux和unix
linux下管道程序求解
来源: 互联网 发布时间:2017-02-28
本文导语: #include #include #include #include #define MAX_CMD_LEN 100 int main() { pid_t child_b,child_c; int pipefds[2]; int i,j; char *pipe_front,*pipe_behind,*guodu; char command[MAX_CMD_LEN]; char *arg1[]={"/usr/bin/wc",NULL}; char *arg2[]={"/b...
#include
#include
#include
#include
#define MAX_CMD_LEN 100
int main()
{
pid_t child_b,child_c;
int pipefds[2];
int i,j;
char *pipe_front,*pipe_behind,*guodu;
char command[MAX_CMD_LEN];
char *arg1[]={"/usr/bin/wc",NULL};
char *arg2[]={"/bin/cat","new_pipe.c",NULL};
char cmd1[MAX_CMD_LEN],cmd2[MAX_CMD_LEN];
//while(1){
printf("please Enter command>");
fgets(command,MAX_CMD_LEN,stdin);
command[strlen(command)-1]=0;
guodu=command;
pipe_front=strsep(&guodu,"|");
pipe_behind=guodu;
for(i=0;i
#include
#include
#include
#define MAX_CMD_LEN 100
int main()
{
pid_t child_b,child_c;
int pipefds[2];
int i,j;
char *pipe_front,*pipe_behind,*guodu;
char command[MAX_CMD_LEN];
char *arg1[]={"/usr/bin/wc",NULL};
char *arg2[]={"/bin/cat","new_pipe.c",NULL};
char cmd1[MAX_CMD_LEN],cmd2[MAX_CMD_LEN];
//while(1){
printf("please Enter command>");
fgets(command,MAX_CMD_LEN,stdin);
command[strlen(command)-1]=0;
guodu=command;
pipe_front=strsep(&guodu,"|");
pipe_behind=guodu;
for(i=0;i