fork()的异步信号安全性

前端之家收集整理的这篇文章主要介绍了fork()的异步信号安全性前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

根据Oracle的Multithreaded Programming Guide,fork()在信号处理程序中应该是安全的.但是我的进程被卡在信号处理程序中,跟随回溯:

 #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可以如何?

提前致谢.

最佳答案
现在是listed as a bug by RedHat

Bug 1422161 – glibc: fork is not async-signal-safe

+++ This bug was initially created as a clone of Bug #1422159 +++

POSIX requires that fork is async-signal-safe. Our current
implementation is not.

原文链接:https://www.f2er.com/linux/440979.html

猜你在找的Linux相关文章