What is the difference between sigaction and signal?

前端 未结 9 804
离开以前
离开以前 2020-11-22 06:23

I was about to add an extra signal handler to an app we have here and I noticed that the author had used sigaction() to set up the other signal handlers. I was

9条回答
  •  耶瑟儿~
    2020-11-22 06:41

    From man page signal(7)

    A process-directed signal may be delivered to any one of the threads that does not currently have the signal blocked. If more than one of the threads has the signal unblocked, then the kernel chooses an arbitrary thread to which to deliver the signal.

    And I would say this "issue" exists for signal(2) and sigaction(2). So be careful with signals and pthreads.

    ... and signal(2) seems to call sigaction(2) underneath in Linux with glibc.

提交回复
热议问题