????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)] = ' 涓荤珯铚樿洓姹犳ā鏉匡細 一级在线播放 | 欧美三级在线观看不卡视频 | 三级黄色视屏 | 日本欧美不卡一区二区三区在线 | 中国女人三级在线播放 | 92国产福利午夜757小视频 | 国产成人免费全部网站 | 成人欧美网站免费 | 99成人免费视频 | 成人网视频在线观看免费 | 日韩欧美国产精品第一页不卡 | 亚洲伊人成综合网 | 黄色影院网站 | 欧美亚洲国产日韩 | haose08永久免费视频 | jizzzz亚洲丰满xxxxⅹ | 在线亚洲黄色 | 妞干网免费在线观看 | 国产精品天天看特色大片不卡 | 亚洲欧美日韩人成 | 欧美三级大片在线观看 | 亚洲日产综合欧美一区二区 | 99在线视频精品 | 91在线欧美 | 亚洲日本va午夜中文字幕 | 亚洲精品福利在线观看 | 欧美亚洲视频 | 欧美一级色 | a视频在线 | xxxxxx日本处大片免费看 | 99热99re8国产在线播放 | 日韩一级二级三级 | 99视频在线精品免费 | 亚洲一区导航 | 中文字幕在线网站 | 新神榜哪吒重生免费高清观看 | 美女色黄 | 在线视频永久在线视频 | 欧美午夜视频一区二区 | 性欧美人妖在线看 | 欧美福利第一页 |