被SIGSEGV传递到每个线程? [英] is SIGSEGV delivered to each thread?

查看:132
本文介绍了被SIGSEGV传递到每个线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux的一个程序,它是多线程的。有些情况下,我很感兴趣,看看他们是否已经在一定时间内书面某​​些内存区域。对于我给只读访问这些内存页和安装SIGSEGV的信号处理程序。现在的问题是,将每个线程调用信号处理程序本身。说线程1写入禁止某些内存区域,会是执行信号处理的人?

I have a program in Linux which is multithreaded. There are certain memory areas in which I'm interested to see if they have been written within a certain time period. For that I give only read access to those memory pages and install a signal handler for SIGSEGV. Now my question is, will each thread call the signal handler for itself. Say Thread 1 writes to some forbidden memory area, will it be the one to execute the signal handler?

推荐答案

中首先

信号性格是进程范围;
  进程中的所有线程共享
  相同配置的每个信号。如果
  一个线程使用的sigaction()来
  建立了处理程序,比如说,SIGINT,
  然后该处理程序可以从被调用
  任何线程到的是SIGINT
  交付。

Signal dispositions are process-wide; all threads in a process share the same disposition for each signal. If one thread uses sigaction() to establish a handler for, say, SIGINT, then that handler may be invoked from any thread to which the SIGINT is delivered.

但读

的信号,可向任
  过程作为一个整体或特定
  螺纹
。一个信号线程定向如果

A signal may be directed to either the process as a whole or to a specific thread. A signal is thread-directed if

它是作为的直接结果产生
  特定的执行
  内的硬件指令
  螺纹( SIGBUS,SIGFPE,SIGILL和SIGSEGV

it is generated as the direct result of the execution of a specific hardware instruction within the context of the thread (SIGBUS, SIGFPE, SIGILL, and SIGSEGV)

我从 TLPI

这篇关于被SIGSEGV传递到每个线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆