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?