A. Harkous A. Harkous - 6 months ago 19
Linux Question

How to set more than one flag in sigaction.sa_flags

I have the following structure:

struct sigaction sa1;
sa1.sa_flags=SA_SIGINFO;
sa1.sa_flags=SA_NODEFER;
sa1.sa_sigaction = handler;
sigaction(SIGUSR1,&sa1,NULL);


How can I use SA_SIGINFO along with SA_NODEFER without making the second flag overrides the first?

Answer

The manual page has the answer:

It is formed by the bitwise OR of zero or more of the following: [...]

So you'd do something like

sa1.sa_flags = SA_NODEFER | SA_SIGINFO;