Which of them is likely to affect the behaviour of my program?
(<glubb> I /knew/ I shouldn't have done it. ;-)
First off, for other readers convenience, here's your example again:
#include <stdio.h>
#include <signal.h>
sig_atomic_t gotsig = 0;
void handler(int signo)
{
gotsig = signo;
}
int main()
{
signal(SIGINT, handler);
puts("Press the interrupt key to exit.");
while (gotsig == 0) ;
printf ("The program received signal %d.\n", (int)gotsig);
return 0;
}
Now, let's see...
1. 7.14#4
An implementation need not generate any of these [1] signals, except
as a result of explicit calls to the raise function. [...]
2. 7.14.1.1#5
If the signal occurs other than as the result of calling the abort or
raise function, the behavior is undefined if the signal handler
refers to any object with static storage duration other than by
assigning a value to an object declared as volatile sig_atomic_t,
[...] ^^^^^^^^