是否可以重复使用相同的struct sigaction
来设置许多信号的处置?例如,以下代码是否有效?
#include <signal.h>
struct sigaction sa; /* global */
void timeout(int sig) { }
void terminate(int sig) { }
void main(void)
{
sa.sa_handler = timeout;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SIGALRM, &sa, NULL);
sa.sa_handler = terminate;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SIGTERM, &sa, NULL);
}