????poll?????梅?????man????????????????????械??????
?????????????
????????????????????????
??????????????????????????????
????????????????????????shell????????500??????????????????"Testing...."
????????????????????
???????????????????????
????Ubuntu10.04:
????poll.cpp?????
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>// waitpid
#include <sys/types.h>// waitpid
#include <string.h>// strlen
#include <poll.h>// poll
/*
comment:
pipe is used between two processes on the same computer.
*/
#define TIMES 50
int main(){
int pipefds[2];
if( -1 == pipe( pipefds)){
printf( "Error when create pipes ");
}else{
int i;
pid_t pid = fork();
if( 0 == pid){// child
printf( "child running ");
close( pipefds[0]);
for( i = 0; i < TIMES; ++ i){
write( pipefds[1]?? "iamagoodguy"?? strlen( "iamagoodguy"));
sleep( 1);
}
}else{
printf( "parent running ");
char buf[256];
close( pipefds[1]);
struct pollfd pf[2];// key structure
pf[0].fd = 0;// console input
pf[0].events = POLLIN;// wait for bytes input
pf[1].fd = pipefds[0];// pipe input
pf[1].events = POLLIN;// wait for bytes input
for( i = 0; i < TIMES; ++ i){
poll( pf?? 2?? 500);// wait for only 500 ms
printf( "Testing... ");
if( pf[1].revents & POLLIN){
buf[ read( pipefds[0]?? buf?? 256)] = ' 涓荤珯铚樿洓姹犳ā鏉匡細 日本波多野结衣在线 | 23部禽女乱小说内裤畸情 | 久久99久久99精品免观看麻豆 | 日韩精品第一 | 婷婷久久综合九色综合98 | 狠狠色成人综合首页 | 黄色的网站免费 | 免费高清资源黄网站在线观看 | 伊人久艹 | 国产欧美日韩视频免费61794 | 成人影视在线 | 久草视频免费 | 欧美乱子伦一区二区三区 | 日韩骚片 | 美女视频ww8888网网 | 丁香婷婷亚洲六月综合色 | 亚洲人成绝费网站色ww | 欧美变态口味重另类牲 | 亚洲人成网站在线播放942一 | 日批视频在线免费看 | 99九九久久 | xx欧美| 印度一级毛片免费的 | 国产欧美日韩在线播放 | 国产看片视频 | 在线免费看黄的网站 | 日韩福利视频高清免费看 | 亚洲激情欧美 | 日韩欧美亚洲中字幕在线播放 | 蜜桃97爱成人 | 97夜夜澡人人爽人人喊一欧美 | 男女羞羞视频免费看 | 午夜一级毛片看看 | 午夜网站在线观看免费网址免费 | 免费看国产一级片 | 国产麻豆媒一区一区二区三区 | 免费特黄一级欧美大片在线看 | 黄色在线视频免费看 | 天天看片天天爽_免费播放 天天看片夜夜爽 | 日本黄免费 | 久久精品网址 |