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)] = '
主站蜘蛛池模板:
欧美日韩亚洲第一页
|
最近中文字幕高清视频2019
|
亚洲日本va中文字幕婷婷
|
做a的视频免费
|
福利网在线观看
|
国产人成午夜免费噼啪视频
|
三级黄色毛片视频
|
国产成人免费高清视频
|
在线资源天堂
|
久久天堂视频
|
青春草视频在线免费观看
|
成人性生交大片免费看午夜a
|
国产一级一级片
|
亚洲va欧美va国产
|
黄色一级大片儿
|
老司机午夜性大片免费
|
一级日本黄色片
|
日韩精品一区二区三区不卡
|
亚洲区精品久久一区二区三区
|
www.色偷偷.com|
欧美一区二区三区不卡免费观看
|
国产麻豆媒一区一区二区三区
|
国产精品麻豆a啊在线观看
国产精品麻豆高清在线观看
|
高清国产一区二区
|
在线免费观看成人
|
噜噜噜噜私人影院av线观看
|
欧美一级高清免费播放
|
在线播放你懂的
|
国产亚洲欧美日韩综合另类
|
久草视频在线免费
|
免费观看欧美一级片
|
欧美亚洲高清
|
欧美二区视频
|
成人高清在线观看播放
|
欧美三级欧美一级
|
在线观看国产wwwa级羞羞视频
|
chinesehihi国产|
男女情趣视频免费播放
|
色视频免费版高清在线观看
|
三级黄色片免费
|
综合欧美日韩一区二区三区
|
|