12419Sdlw /* 2*2544Sdlw char id_signal[] = "@(#)signal_.c 1.2"; 32419Sdlw * 42419Sdlw * change the action for a specified signal 52419Sdlw * 62419Sdlw * calling sequence: 72419Sdlw * integer cursig, signal, savsig 82419Sdlw * external proc 92419Sdlw * cursig = signal(signum, proc, flag) 102419Sdlw * where: 112419Sdlw * 'cursig' will receive the current value of signal(2) 122419Sdlw * 'signum' must be in the range 0 <= signum <= 16 132419Sdlw * 142419Sdlw * If 'flag' is negative, 'proc' must be an external proceedure name. 152419Sdlw * 162419Sdlw * If 'flag' is 0 or positive, it will be passed to signal(2) as the 172419Sdlw * signal action flag. 0 resets the default action; 1 sets 'ignore'. 182419Sdlw * 'flag' may be the value returned from a previous call to signal. 19*2544Sdlw * 20*2544Sdlw * This routine arranges to trap user specified signals so that it can 21*2544Sdlw * pass the signum fortran style - by address. (boo) 222419Sdlw */ 232419Sdlw 242419Sdlw #include "../libI77/f_errno.h" 252419Sdlw 26*2544Sdlw int (*dispatch[17])(); 272419Sdlw int (*signal())(); 28*2544Sdlw int sig_trap(); 292419Sdlw 302419Sdlw long signal_(sigp, procp, flag) 312419Sdlw long *sigp, *flag; 322419Sdlw int (*procp)(); 332419Sdlw { 342419Sdlw if (*sigp < 0 || *sigp > 16) 352419Sdlw return(-((long)(errno=F_ERARG))); 362419Sdlw 372419Sdlw if (*flag < 0) /* function address passed */ 38*2544Sdlw { 39*2544Sdlw dispatch[*sigp] = procp; 40*2544Sdlw return((long)signal((int)*sigp, sig_trap) ); 41*2544Sdlw } 422419Sdlw 432419Sdlw else /* integer value passed */ 442419Sdlw return((long)signal((int)*sigp, (int)*flag) ); 452419Sdlw } 46*2544Sdlw 47*2544Sdlw sig_trap(sn) 48*2544Sdlw int sn; 49*2544Sdlw { 50*2544Sdlw long lsn = (long)sn; 51*2544Sdlw return((*dispatch[sn])(&lsn)); 52*2544Sdlw } 53