当前位置: 技术问答>linux和unix
请问popen函数据第二个参数const char *type设为“w”是什么意思,man写的太简单了不明白?
来源: 互联网 发布时间:2015-09-09
本文导语: 请问popen函数据第二个参数const char *type设为“w”是什么意思,man写的太简单了不明白? | popen的作用是创建一个管道并启动一个进程,该进程根据type参数从该管道读出标准输入或是往该管道...
请问popen函数据第二个参数const char *type设为“w”是什么意思,man写的太简单了不明白?
|
popen的作用是创建一个管道并启动一个进程,该进程根据type参数从该管道读出标准输入或是往该管道写入标准输出,如果还是不理解,我记得APUE的进程通信部分是有个popen的实现的,楼主可以好好看看
|
If mode is r, when the child process is started its file descriptor STDOUT_FILENO will be the writable end of the pipe, and the file descriptor fileno(stream) in the calling process, where stream is the stream pointer returned by popen(), will be the readable end of the pipe.
If mode is w, when the child process is started its file descriptor STDIN_FILENO will be the readable end of the pipe, and the file descriptor fileno(stream) in the calling process, where stream is the stream pointer returned by popen(), will be the writable end of the pipe.
If mode is w, when the child process is started its file descriptor STDIN_FILENO will be the readable end of the pipe, and the file descriptor fileno(stream) in the calling process, where stream is the stream pointer returned by popen(), will be the writable end of the pipe.