IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> [C][POSIX][API]运行其它程序,并重定向输入输出
猫猫草
post 2013-04-17 22:41:12, Wed
Post #1


猫猫猫
***

Group: Power Cat
Posts: 626
Joined: 2006-12-8
Member No.: 2



程序模型:

代码
pipe(rpipes);
pipe(wpipes);

fork()
child:
   close(wpipes[1]);
   close(rpipes[0]);
   dup2(wpipes[0], STDIN);
   dup2(rpipes[1], STDOUT);
   close(wpipes[0]);
   close(rpipes[1]);
   exec(..)
parent:
   close(wpipes[0]);
   close(rpipes[1]);
   //write to stdin
   write(wpipes[1], ...);
   //read from stdout
   read(rpipes[0], ...);
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 2024-12-25 01:55