请教:超时错ETIMEDOUT ??

小弟用下面的程序段,来测试 超时错ETIMEDOUT,但是,实际测试,得到的错一直是errno=4,Interrupted function call 错。我的程序是不是有什么地方写错了啊??

sprintf(buf,“mq 9 %03d\n”,k);
clock_gettime(CLOCK_REALTIME, &tm);
tm.tv_sec += 1;
if((res=mq_timedsend(msgQId, buf, strlen(buf), prio, &tm)) < 0) {//res=0->ok
save_errno = errno;
fprintf(stderr,"\nmsgQSend failed[%d]!!",save_errno);
if(save_errno == ETIMEDOUT){
printf("\nETIMEDOUT");
sleep(5);
}
}
else
{k++;}

你的程序没有错,这个是系统实现的问题。暂时除了把EINTR当作ETIMEOUT一样以外,没有别的办法。:smiley:

哦,我明白了,谢谢你!!!