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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:33:29+00:00 2026-05-27T17:33:29+00:00

If I send multiple subsequent Hangup signals to the following program, only two of

  • 0

If I send multiple subsequent Hangup signals to the following program, only two of them would be handled and the rest will be ignored:

#include <stdio.h>
#include <unistd.h>
#include <signal.h>

int id;
void handler(int s)
{
    id++;
    int i;
    for(i=0; i<3; i++)
    {
        printf("Sig %d\n", id);
        sleep(2);
    }
}

int main()
{
    int i;
    signal(SIGHUP, handler);
    for( i=0; ; i++ )
    {
        printf("%d\n", i);
        sleep(1);
    }
    return 0;
}

I use the following command to send signal to the process:

kill -l {#process}

If I run the above command three times consecutively, the 3rd signal will be ignored as in the following output:

0
1
2
3
4
5
6
7
Sig 1
Sig 1
Sig 1
Sig 2
Sig 2
Sig 2
8
9
10
11
12

Is there any way to catch the third signal too?

  • 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-27T17:33:29+00:00Added an answer on May 27, 2026 at 5:33 pm

    Normally, you can’t do it with standard signals. Unix kernel generally queues up only one pending signal. If Sig2 and Sig3 are sent while process sleeping in Sig1 handler, they are merged.

    You can use sigaction(2) to set up your signal handler and supply SA_NODEFER flag to it. It will allow to deliver new signal while still in signal handler. Make sure your handler is reenterant, it’s error-prone solution.

    Also there is POSIX.1b (POSIX.1-2001) extension called “real-time signals”. Such signals can be queued multiple times, but SIGHUP isn’t one of them. signal(7) on Linux states that real-time signals are numbered 33 (SIGRTMIN) to 64 (SIGRTMAX).

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

Sidebar

Related Questions

I would like to send multiple HTTP requests to a server, using pipelining where
I am using php mailer class to send multiple attachment mails. Two error are
I'm trying to figure out how to send multiple fields with AJAX. Would I
I am new to C/C++. I am using the following code to send multiple
I'm writing a Java desktop client which will send multiple files over the wire
I would like to send multiple records to a website after reading the records
I want to send multiple attachments but not declaring them just octet-stream doing it
How to send multiple image in an email? I would greatly prefer the image
This program is running but how to send multiple CC and BCC. for($i =
I have a jsp page where I'm trying to send multiple (two currently) ajax

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.