Example: Portable OpenSSH cvs-20051008 openbsd-compat/bsd-misc.c 189| mysig_t 190| mysignal(int sig, mysig_t act) 191| { 192| #ifdef HAVE_SIGACTION 193| struct sigaction sa, osa; 194| 195| if (sigaction(sig, NULL, &osa) == -1) 196| return (mysig_t) -1; 197| if (osa.sa_handler != act) { 198| memset(&sa, 0, sizeof(sa)); 199| sigemptyset(&sa.sa_mask); 200| sa.sa_flags = 0; 201| #ifdef SA_INTERRUPT 202| if (sig == SIGALRM) 203| sa.sa_flags |= SA_INTERRUPT; 204| #endif 205| sa.sa_handler = act; 206| if (sigaction(sig, &sa, NULL) == -1) 207| return (mysig_t) -1; 208| } 209| return (osa.sa_handler); 210| #else 211| #undef signal 212| return (signal(sig, act)); 213| #endif 214| }