- 论坛徽章:
- 0
|
环境: HP-UX 11 c语言编程
目的是使用select做定时器
源代码如下:
#include <stdio.h>;
#include <stdlib.h>;
#include <sys/time.h>;
#include <sys/types.h>;
#include <unistd.h>;
int
main(void)
{
int ret;
struct timeval delay;
time_t t1,t2;
delay.tv_sec =0 ;
delay.tv_usec = 1000000;
time(&t1);
ret = select(0,NULL,NULL,NULL,&delay);
time(&t2);
if (ret == -1)
{
printf(\"select error!!\\n\" ;
return -1;
}
printf(\"end-start time is %d\\n\",t2-t1);
return 0;
}
编译 cc -g select.c
执行 ./a.out
结果输出select error!!
但是在linux7.2下就能输出1,
请大家帮忙看看是怎么回事?多谢了 |
|