Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5992701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:34:13+00:00 2026-05-22T23:34:13+00:00

The Linux Programming Interface Book has mentioned a method for dealing with asynchronous signals

  • 0

The Linux Programming Interface Book has mentioned a method for dealing with asynchronous signals in a multi threaded program:

  • All threads block all of the asynchronous signals that the process
    might receive. The simplest way to do
    this is to block the signals in the
    main thread before any other thread
    are created. Each subsequently created
    thread will inherit a copy of the main
    thread’s signal mask.
  • create a single dedicated thread that accepts incoming signals using
    sigwaitinfo(), sigtimedwait() or
    sigwait().

The advantage of this approach is that
asynchronously generated signals are
received synchronously. As it accepts
incoming signals, the dedicated thread
can safely modify shared variables
(under mutex control) and call
non-async-safe functions. It can also
signal condition variables, and emply
other thread and process communication
and synchronization mechanisms.

Now the questions:

  1. when kernel wants to deliver signals it choose one of the threads inside process arbitrary. from where it can know to deliver signal to the dedicated thread?
  2. pthread API is non-aync-safe functions. so how we can use them inside signal handler?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:34:14+00:00Added an answer on May 22, 2026 at 11:34 pm

    When the kernel delivers a process-directed signal, it chooses one of the threads that does not have the signal blocked. This means that it never chooses any of the threads apart from the signal-handling thread (which acts like it has the signal unblocked while it is blocked in sigwaitinfo() or similar). In other words: the kernel knows where to deliver the signal, because you have arranged things such that the signal-handling thread is the only thread that is ever allowed to deliver the signal to.

    You do not use the pthreads API, or any non-async-signal-safe functions in a signal handler. The solution outlined does not handle the signals within signal handlers – it handles the signals within the normal execution flow of the signal-handling thread, after sigwaitinfo() returns. This allows it to access non-async-signal-safe functions, which is the whole point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Linux Programming Interface book has a piece of code (producer/consumer) to show how
This is sample program from Beginning Linux Programming book: #include <stdio.h> #include <term.h> #include
I am learning socket programming under Linux,so I make a sample program to list
I am new to linux c programming and i have a simple program just
I usually prefer linux for programming( i program in django on Ubuntu). But often
This example is taken from the Linux System Programming book, page 88. Code: http://pastebin.com/mEfmHbPP
I am in the middle of reading The Linux Programming Interface and Linux programming
My problem is the following: I'm programming an Interface in Linux to control a
New to Linux programming in general. I am trying to communicate with a kernel
Here is a challenge question I've got from Linux system programming lecture. Any of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.