fork()的异步信号安全性 [英] Async signal safety of fork()
本文介绍了fork()的异步信号安全性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据Oracle的《多线程编程指南》 ,fork()
应该在信号处理程序中可以安全使用.但是我的进程陷入了信号处理程序的内部,并跟踪以下回溯:
According to Oracle's Multithreaded Programming Guide, fork()
should be safe-to-use inside signal handlers. But my process got stuck inside signal handler with to following back trace:
#0 __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
#1 0x00007f86e6a9990d in _L_lock_48 () from /lib/x86_64-linux- gnu/libc.so.6
#2 0x00007f86e6a922ec in ptmalloc_lock_all () at arena.c:242
#3 0x00007f86e6ad5e82 in __libc_fork () at ./nptl/sysdeps/unix/sysv/linux/x86_64/../fork.c:95
#4 0x00007f86e7d9f125 in __fork () at ./nptl/sysdeps/unix/sysv/linux/pt-fork.c:25
....
#7 signal handler called
所以malloc
在信号处理程序中不能安全使用fork
怎么可能?
So as malloc
is not safe to be use in signal handler how fork
can be?
谢谢.
推荐答案
现在为被RedHat列为错误:
错误1422161-glibc:叉子不是异步信号安全的
...
+++该错误最初是作为错误#1422159 +++的克隆而创建的
+++ This bug was initially created as a clone of Bug #1422159 +++
POSIX要求fork是异步信号安全的.我们目前 实施不是.
POSIX requires that fork is async-signal-safe. Our current implementation is not.
这篇关于fork()的异步信号安全性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文