即使使用 SA_RESTART,哪些功能也会被信号中断?

发布于 2024-10-25 21:20:51 字数 215 浏览 1 评论 0原文

是否有任何相当完整的列表,说明在接收或处理信号时,POSIX 中的哪些函数会被 EINTR 中断,即使没有信号处理程序或者处理程序是通过 SA_RESTART 安装的代码>?一些示例:

  • select
  • nanosleep
  • 等。

Is there any reasonably complete list of which functions in POSIX are interrupted with EINTR when a signal is received or handled, even if there is no signal handler or if the handler was installed with SA_RESTART? Some examples:

  • select
  • nanosleep
  • etc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

顾铮苏瑾 2024-11-01 21:20:51

tcsetattr 也不可重新启动,至少在 Linux 2.6.18 中是这样

tcsetattr is also not restartable, at least in Linux 2.6.18

半岛未凉 2024-11-01 21:20:51

POSIX 说:

如果信号捕获函数执行 return 语句,则被中断函数的行为应如该函数单独描述的那样,除非不安全函数另有说明。

因此,要么单独查看所有函数,要么过滤手册页中的 EINTR 和 POSIX。我做了后者并得到:

接受,
aio_挂起,
猫关闭,
猫,
chmod,
乔恩,
时钟_nanosleep,
关闭,
关闭,
连接,
重复,
错误,
执行,
错位,
fchdir,
fchmod,
fchown,
f关闭,
fcntl,
冲洗,
fgetc,
fgetwc,
福开,
叉,
fputc,
fputwc,
自由开放,
查找,
fsetpos,
同步,
截断,
格伦特,
获取gid,
得到格南,
获取消息,
得到了,
获取pwnam,
获取pwuid,
读写控制,
尔乔恩,
lio_listio,
洛克夫,
MQ_打开,
MQ_接收,
MQ_发送,
毫秒戈普,
消息grcv,
消息,
纳米睡眠,
打开,
暂停,
关闭,
轮询,
posix_fallocate,
posix_mem_offset,
posix_trace_create,
posix_trace_get_filter,
posix_trace_getnext_event,
posix_trace_open,
posix_trace_start,
posix_typed_mem_get_info,
posix_typed_mem_open,
打印,
pthread_atfork,
pthread_attr_getdetachstate,
pthread_attr_getguardsize,
pthread_attr_getinheritsched,
pthread_attr_getschedparam,
pthread_attr_getschedpolicy,
pthread_attr_getscope,
pthread_attr_getstack,
pthread_attr_getstackaddr,
pthread_attr_getstacksize,
pthread_attr_init,
pthread_barrier_init,
pthread_barrier_wait,
pthread_barrierattr_getpshared,
pthread_barrierattr_init,
pthread_取消,
pthread_cleanup_push,
pthread_cond_init,
pthread_cond_signal,
pthread_cond_wait,
pthread_condattr_getclock,
pthread_condattr_getpshared,
pthread_condattr_init,
pthread_create,
pthread_detach,
pthread_equal,
pthread_getconcurrency,
pthread_getschedparam,
pthread_getspecific,
pthread_join,
pthread_key_create,
pthread_key_delete,
pthread_kill,
pthread_mutex_getprioceiling,
pthread_mutex_init,
pthread_mutex_lock,
pthread_mutex_timedlock,
pthread_mutexattr_getprioceiling,
pthread_mutexattr_getprotocol,
pthread_mutexattr_getpshared,
pthread_mutexattr_gettype,
pthread_mutexattr_init,
pthread_once,
pthread_rwlock_init,
pthread_rwlock_rdlock,
pthread_rwlock_timedrdlock,
pthread_rwlock_timedwrlock,
pthread_rwlock_unlock,
pthread_rwlock_wrlock,
pthread_rwlockattr_getpshared,
pthread_rwlockattr_init,
pthread_self,
pthread_setschedprio,
pthread_spin_init,
pthread_spin_lock,
pthread_spin_unlock,
pthread_testcancel,
放置消息,
读,
接收,
接收来自,
接收消息,
扫描,
选择,
选择图特,
SEM_打开,
sem_timedwait,
SEM_等待,
塞姆普,
发送,
发送消息,
发送到,
shm_打开,
信号动作,
信号中断,
暂停,
sigproc掩码,
符号集,
信号暂停,
西格维克,
信号等待信息,
统计数据,
状态文件系统,
系统,
tcdrain,
tcsetattr,
临时文件,
截短,
阿拉尔警报,
我们睡觉,
等待,
等待和

POSIX says:

If the signal-catching function executes a return statement, the behavior of the interrupted function shall be as described individually for that function, except as noted for unsafe functions.

So, either you look through all functions individually or filter your man pages for EINTR and POSIX. I did the latter and got:

accept,
aio_suspend,
catclose,
catgets,
chmod,
chown,
clock_nanosleep,
close,
closedir,
connect,
dup,
errno,
exec,
fallocate,
fchdir,
fchmod,
fchown,
fclose,
fcntl,
fflush,
fgetc,
fgetwc,
fopen,
fork,
fputc,
fputwc,
freopen,
fseek,
fsetpos,
fsync,
ftruncate,
getgrent,
getgrgid,
getgrnam,
getmsg,
getpwent,
getpwnam,
getpwuid,
ioctl,
lchown,
lio_listio,
lockf,
mq_open,
mq_receive,
mq_send,
msgop,
msgrcv,
msgsnd,
nanosleep,
open,
pause,
pclose,
poll,
posix_fallocate,
posix_mem_offset,
posix_trace_create,
posix_trace_get_filter,
posix_trace_getnext_event,
posix_trace_open,
posix_trace_start,
posix_typed_mem_get_info,
posix_typed_mem_open,
printf,
pthread_atfork,
pthread_attr_getdetachstate,
pthread_attr_getguardsize,
pthread_attr_getinheritsched,
pthread_attr_getschedparam,
pthread_attr_getschedpolicy,
pthread_attr_getscope,
pthread_attr_getstack,
pthread_attr_getstackaddr,
pthread_attr_getstacksize,
pthread_attr_init,
pthread_barrier_init,
pthread_barrier_wait,
pthread_barrierattr_getpshared,
pthread_barrierattr_init,
pthread_cancel,
pthread_cleanup_push,
pthread_cond_init,
pthread_cond_signal,
pthread_cond_wait,
pthread_condattr_getclock,
pthread_condattr_getpshared,
pthread_condattr_init,
pthread_create,
pthread_detach,
pthread_equal,
pthread_getconcurrency,
pthread_getschedparam,
pthread_getspecific,
pthread_join,
pthread_key_create,
pthread_key_delete,
pthread_kill,
pthread_mutex_getprioceiling,
pthread_mutex_init,
pthread_mutex_lock,
pthread_mutex_timedlock,
pthread_mutexattr_getprioceiling,
pthread_mutexattr_getprotocol,
pthread_mutexattr_getpshared,
pthread_mutexattr_gettype,
pthread_mutexattr_init,
pthread_once,
pthread_rwlock_init,
pthread_rwlock_rdlock,
pthread_rwlock_timedrdlock,
pthread_rwlock_timedwrlock,
pthread_rwlock_unlock,
pthread_rwlock_wrlock,
pthread_rwlockattr_getpshared,
pthread_rwlockattr_init,
pthread_self,
pthread_setschedprio,
pthread_spin_init,
pthread_spin_lock,
pthread_spin_unlock,
pthread_testcancel,
putmsg,
read,
recv,
recvfrom,
recvmsg,
scanf,
select,
select_tut,
sem_open,
sem_timedwait,
sem_wait,
semop,
send,
sendmsg,
sendto,
shm_open,
sigaction,
siginterrupt,
sigpause,
sigprocmask,
sigset,
sigsuspend,
sigvec,
sigwaitinfo,
statfs,
statvfs,
system,
tcdrain,
tcsetattr,
tmpfile,
truncate,
ualarm,
usleep,
wait,
waitid and
write

夏尔 2024-11-01 21:20:51

如果有人想知道,signal(7) 的手册页有更多关于什么是重新启动和什么没有重新启动的详细信息:

If anyone wonders, the manpage for signal(7) has more detail on what is and what isn't restarted:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文