加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

fork()的异步信号安全性

发布时间:2020-12-13 13:51:35 所属栏目:Linux 来源:网络整理
导读:根据Oracle的Multithreaded Programming Guide,fork()在信号处理程序中应该是安全的.但是我的进程被卡在信号处理程序中,跟随回溯: #0 __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 #1 0x00007f86e6a9990d in _

根据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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读