- 论坛徽章:
- 1
|
回复 #1 fantasticeb 的帖子
struct restart_block restart_block;
# 这个可能与重新启动系统调用有关
看了一下select.c中的一段代码
869static long do_restart_poll(struct restart_block *restart_block)
870{
871 struct pollfd __user *ufds = restart_block->poll.ufds;
872 int nfds = restart_block->poll.nfds;
873 struct timespec *to = NULL, end_time;
874 int ret;
875
876 if (restart_block->poll.has_timeout) {
877 end_time.tv_sec = restart_block->poll.tv_sec;
878 end_time.tv_nsec = restart_block->poll.tv_nsec;
879 to = &end_time;
880 }
881
882 ret = do_sys_poll(ufds, nfds, to);
883
884 if (ret == -EINTR) {
885 restart_block->fn = do_restart_poll;
886 ret = -ERESTART_RESTARTBLOCK;
887 }
888 return ret;
889}
# 注意这里的ret == -EINTR
# 在系统编程中,如果返回该值可以重新尝试发起中断的系统调用
# 这里应该也是用作内部参数或者其他信息的记录的
# 这样当系统调用失败以后,记录下来,然后若是系统支持重启动系统调用
# 那么可以重新尝试一下
# 搜了一下,用到它的场合不多,可能与具体对应的系统调用的语义有关系
# 可以看一下APUE2的10.5. Interrupted System Calls
# 具体内核中的实现可以参考一下相关的POSIX语义,比如poll、select函数 |
|