在linux的C library中 , 提供了popen() function可以讓我們建立相同於pipeline的功能 ,

popen()的format如下:

FILE *popen(const char *command, const char *mode);

簡單的想 , popen會先執行command , 並傳回一個file pointer 指向該command output的內容, 

接下來我們便可以藉由這個file pointer對output的內容進行操作.

fp = popen(fullcmd,"r");

其中r --> read , 而w則代表write.

 

ref : http://pubs.opengroup.org/onlinepubs/7908799/xsh/popen.html

文章標籤
全站熱搜
創作者介紹
創作者 JerryCheng 的頭像
JerryCheng

KwCheng's blog

JerryCheng 發表在 痞客邦 留言(0) 人氣(451)