Linux 我需要glibc提供的异步信号安全函数列表
非系统调用的包装,但类似于snprintf(),dprintf()我很确定您必须看到 编辑: 那怎么样 从Linux 我需要glibc提供的异步信号安全函数列表,linux,list,libc,async-safe,Linux,List,Libc,Async Safe,非系统调用的包装,但类似于snprintf(),dprintf()我很确定您必须看到 编辑: 那怎么样 从人工信号: NOTES The effects of this call in a multi-threaded process are unspecified. The routine handler must be very careful, since processing elsewhere was interrupted at some arbitra
人工信号
:
NOTES
The effects of this call in a multi-threaded process are unspecified.
The routine handler must be very careful, since processing elsewhere
was interrupted at some arbitrary point. POSIX has the concept of "safe
function". If a signal interrupts an unsafe function, and handler
calls an unsafe function, then the behavior is undefined. Safe func-
tions are listed explicitly in the various standards. The POSIX.1-2003
list is
_Exit() _exit() abort() accept() access() aio_error() aio_return()
aio_suspend() alarm() bind() cfgetispeed() cfgetospeed() cfsetispeed()
cfsetospeed() chdir() chmod() chown() clock_gettime() close() connect()
creat() dup() dup2() execle() execve() fchmod() fchown() fcntl() fdata-
sync() fork() fpathconf() fstat() fsync() ftruncate() getegid()
geteuid() getgid() getgroups() getpeername() getpgrp() getpid() getp-
pid() getsockname() getsockopt() getuid() kill() link() listen()
lseek() lstat() mkdir() mkfifo() open() pathconf() pause() pipe()
poll() posix_trace_event() pselect() raise() read() readlink() recv()
recvfrom() recvmsg() rename() rmdir() select() sem_post() send()
sendmsg() sendto() setgid() setpgid() setsid() setsockopt() setuid()
shutdown() sigaction() sigaddset() sigdelset() sigemptyset() sig-
fillset() sigismember() signal() sigpause() sigpending() sigprocmask()
sigqueue() sigset() sigsuspend() sleep() socket() socketpair() stat()
symlink() sysconf() tcdrain() tcflow() tcflush() tcgetattr() tcgetp-
grp() tcsendbreak() tcsetattr() tcsetpgrp() time() timer_getoverrun()
timer_gettime() timer_settime() times() umask() uname() unlink()
utime() wait() waitpid() write().
According to POSIX, the behaviour of a process is undefined after it
ignores a SIGFPE, SIGILL, or SIGSEGV signal that was not generated by
the kill(2) or the raise(3) functions. Integer division by zero has
undefined result. On some architectures it will generate a SIGFPE sig-
nal. (Also dividing the most negative integer by -1 may generate
SIGFPE.) Ignoring this signal might lead to an endless loop.
See sigaction(2) for details on what happens when SIGCHLD is set to
SIG_IGN.
The use of sighandler_t is a GNU extension. Various versions of libc
predefine this type; libc4 and libc5 define SignalHandler, glibc
defines sig_t and, when _GNU_SOURCE is defined, also sighandler_t.
这似乎很难确定,因为您不知道库例程可能决定调用什么随机不安全函数。不同版本的glibc之间的列表也可能不同,或者如果您将其带到另一个类似Unix的系统中,列表也可能不同。似乎您必须分析许多调用堆栈才能找到答案,甚至在版本之间、发行版与发行版之间,这些调用堆栈也可能有点不稳定 也许你不是在寻找替代的设计方法,但似乎更好的策略是:如果你的程序有一个事件循环,那么让信号处理程序变得非常愚蠢,只是设置一些事件循环将拾取的状态。这样,您就可以在信号处理程序之外完成有意义的工作 示例:假设您在某处有一个
poll()
循环。也许您可以包含一个信号处理程序可以写入的管道。然后,poll()
循环根据它发出的信号执行一些不平凡的工作
在应用程序崩溃后,我需要在SIGSEGV处理程序中使用它 我要在撞车时放卷 如果您试图捕获堆栈跟踪:
- 通常,
会导致核心转储,可通过调试器运行该转储以生成堆栈跟踪abort
- 或者,一种粗糙(但信号安全)的方法是使用
和fork
一个单独的实用程序(例如“pstack”)来输出崩溃任务的堆栈跟踪。当exec
-ing(在exec
-ing之后,在子进程中)时,需要使用fork
传递进程ID;在父级中,您需要等待它完成,然后再调用getppid
abort
最后,man 7 signal safety的最新版本包含感兴趣的列表:在应用程序崩溃后,我需要在SIGSEGV处理程序中使用该列表。该列表是系统调用列表。我记得很清楚。但我需要GLIBC的函数列表是的,该列表主要由系统调用组成,但GLIBC就是这样;系统接口。我认为其他标准C函数不是信号安全的,因为它们没有在这里列出,或者至少我找不到任何权威指针指向列出它们的其他(POSIX)标准。GLIBC的strcat、strcopy是信号安全的。这是不标准的,但确实如此。我对更多类似的功能感兴趣。strcat/strcpy的源是信号安全的吗?是的,strcat、strcpy、strcpy、strmp、strlen的源是信号安全的。
man 7信号
和搜索异步信号安全
,会有一个列表。你还没有理解我的问题。为什么你接受的答案中的内容是在man 7 signal
中呢?@CodyChan对不起,这是自动接受的,因为我使用了赏金。