Linux?????poll???????÷?
???????????? ???????[ 2013/12/17 10:50:05 ] ????????
????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)] = '
主站蜘蛛池模板:
国产成人综合一区精品
|
风流放荡的艳妇小说
|
国产大片黄在线看免费
|
成人毛片手机版免费看
|
精品无码一区在线观看
|
k9女士 hd|
天天干夜夜躁
|
亚洲韩国欧美一区二区三区
|
日本人69视频
|
狠狠的撞进去嗯啊h女强男视频
|
激情小说五月
|
黄色小视频在线播放
|
一本三道a无线码一区v
|
2021免费日韩视频网
|
日韩欧美在线综合网
|
亚洲无限乱码一二三四区
|
免费永久在线观看污污的网站
|
欧美日韩第一区
|
999成人国产精品
|
91免费视|
欧美一级精品高清在线观看
|
欧美日韩一区二区三区四区
|
肉动漫成人免费无遮羞
|
日韩中文字幕视频在线
|
九九精品九九
|
免费一级黄色毛片
|
h成人在线
|
亚洲永久免费网站
|
动漫精品专区一区二区三区不卡
|
国产91成人精品亚洲精品
|
毛片免费永久不卡视频观看
|
波多野结衣在线中文字幕
|
久久精品国产波多野结衣
|
欧美人禽|
久久精品国产精品亚洲艾
|
一级毛片在线观看免费
|
欧美视|
在线观看黄色毛片
|
好看的看黄a大片爽爽影院
好黄好猛好爽好痛的视频
好吊爽在线播放视频
|
天天摸天天碰中文字幕
|
看黄的视频
|
|