????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)] = ' 主站蜘蛛池模板: 免费在线视频成人 | 性香港xxxxx免费视频播放 | 日韩欧美一区在线观看 | 最近2019年中文字幕6 | 在线看福利片 | 深夜免费在线观看 | 国产成人亚综合91精品首页 | 欧美亚洲综合在线 | 妞干网在线观看视频 | 操操网址 | 天天躁夜夜躁狠狠躁2021a | 欧美精品一区二区三区四区 | aaa影院 | 天天干天天色综合 | 手机看片高清日韩精品 | 一级做a爱片性色毛片武则天五则 | 欧美日本高清一本二本三本 | 欧美视频综合 | 九月婷婷人人澡人人添人人爽 | 亚洲 中文 欧美 日韩 在线人 | 色网站免费视频 | 日韩激情在线播放 | 夜夜骑首页 | 乱理最新乱理片中文 | 国产精品资源在线观看网站 | 欧美成人一区二区三区不卡 | 亚洲色图欧美一区 | 国产粉嫩嫩00在线正在播放 | 亚洲乱码一二三四区国产 | 亚洲欧美日韩综合在线播放 | 日本三日本三级香港三级 | 美国成人免费视频 | 日日插日日操 | 免费看a毛片 | 丁香六月综合网 | 一区二区三区日韩精品 | 综合成人| 黄色欧美视频 | 激情影院a | 日韩高清网站 | 亚洲欧美日韩一区高清中文字幕 |