[C][POSIX][API]运行其它程序,并重定向输入输出 |
[C][POSIX][API]运行其它程序,并重定向输入输出 |
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], ...); |
|
|
Lo-Fi Version | Time is now: 2024-11-1 10:41 |