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 6993027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:42:42+00:00 2026-05-27T19:42:42+00:00

I have to send two signals to a process, SIGUSR1 and SIGUSR2 , in

  • 0

I have to send two signals to a process, SIGUSR1 and SIGUSR2, in order to modify a particular boolean variable in the program (SIGUSR1 sets it to true, SIGUSR2 sets it to false). So I wrote a signalHandler() function in order to control the behavior of SIGUSR1 or SIGUSR2. The problem is: how to set sigaction() to handle this particular task? I spent a lot of time on Google, I read everywhere that I should use sigaction() instead of the obsolete signal(). In the man page i found this

int sigaction(int signum, const struct sigaction *act,struct sigaction *oldact);

in signum I have to put the type of signal I want to handle, then I have a struct sigaction parameter:

  struct sigaction {
       void     (*sa_handler)(int);
       void     (*sa_sigaction)(int, siginfo_t *, void *);
       sigset_t   sa_mask;
       int        sa_flags;
       void     (*sa_restorer)(void);
   };

in the first field i thought i should set the name of my signal handler, but I don’t know how can I set the other fields.

Finally, what is the use of: struct sigaction *oldact?

  • 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-27T19:42:43+00:00Added an answer on May 27, 2026 at 7:42 pm

    See the sigaction(2) manual page. It’s all described there.

    Basically you set either sa_handler or sa_sigaction depending on whether you want the extra signal info.

    If you set the later, you need to add SA_SIGINFO to the flags. Otherwise the flags should probably be 0 for your case. You probably want system calls to fail with errno EINTR when interrupted with the signal (default behaviour), so you can consider the new value of the variable before restarting them, but if you ended up wanting to restart them automatically (select and poll are never restarted), you can set the SA_RESTART flag.

    The sa_mask is set of signals that should be defered while this singal handler is running. You should set at least the two signals, so they don’t get mixed up if they come in quick succession.

    And the last, sa_restorer is obsolete and unused anyway.

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

Sidebar

Related Questions

After user places an order I have to send detailed email message containing order
I have a program to send POST request to a server. I'm using cURL
I have to send signal and data between two objects. The reciever have to
I have to send a two-dimensional JavaScript Array to a PHP page. Indeed, I'm
I have to send parameters between two UIView. This is how I'm loading the
I have a program that I need to use signals and handlers with. I
I have two threads in a process. These two threads have a race to
I have two process and a shared memory zone, my workflow is like this.
I have to send two strings from java android code to php script. I
I have a jqgrid and on button click I just want to send two

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.