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

  • Home
  • SEARCH
  • 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 7016845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:50:18+00:00 2026-05-27T22:50:18+00:00

The code I’m working with has a shared signal handler that switches on the

  • 0

The code I’m working with has a shared signal handler that switches on the signal number to handle it appropriately.

I’m adding a custom signal. Something like this

static void signal_handler (int s)
{
    if ( s == SIGTERM ) clean_up () ;

    else if ( s == SIGRTMIN+1 ) ; // do nothing
}

SIGRTMIN and SIGRTMAX are #defines of function calls which initialize static data (in the implementations I’ve seen on google code search)

Signal handlers are supposed to be non-reentrant. Does the use of static data in the accessor to SIGRTMIN and SIGRTMAX make these macros unsafe to use in a 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-27T22:50:18+00:00Added an answer on May 27, 2026 at 10:50 pm

    I don’t know what implementation you are smoking, but in libc those functions seem to simply return a constant static variable most of the time.

    You are right, there is a possible race between the two calls to init(), but that simply just initializes a static int twice to the same constant, hardly a worry.

    And, while the static variable is not really that constant, they tell you to only modify said variable at the start of your program(and I think only pthread really modifies it that much).

    So no need to worry about these functions(from allocrtsig.c glibc 2.14).

    And, if you are really worried, just call SIGRTMIN once before you bind the signal handler. That will get the init() function out of the way.

    /* Return number of available real-time signal with highest priority.  */
    int __libc_current_sigrtmin (void)
    {
    #ifdef __SIGRTMIN
      if (!initialized)
        init ();
    #endif
      return current_rtmin;
    }
    libc_hidden_def (__libc_current_sigrtmin)
    
    /* Return number of available real-time signal with lowest priority.  */
    int __libc_current_sigrtmax (void)
    {
    #ifdef __SIGRTMIN
      if (!initialized)
        init ();
    #endif
      return current_rtmax;
    }
    libc_hidden_def (__libc_current_sigrtmax)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code that was working fine last week is suddenly throwing this exception: System.Data.SqlClient.SqlException (0x80131904):
Code below is not working as expected to detect if it is in design
Code that is untestable really annoys me. The following things make oo-code untestable: global
(code examples are python) Lets assume we have a list of percentages that add
I've got a string that has curly quotes in it. I'd like to replace
Code for webpage such that if anyone closes it, then next time when he
Code Currently my code looks like that. $stmt = $this->db->prepare(SELECT m.id, m.from_id, m.to_id, m.subject,
code structure @protocal A_Delegate { -(void)doIt:(BOOL)isDone; } Super Class A // has properties of
Code is simplified to make it clearer. The description I'm writing a custom control
Code #include <OOLua/oolua.h> class foo { public: int bar(); }; OOLUA_CLASS_NO_BASES(foo)//class has no bases

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.