1: /* 2: * Copyright (c) 1980 Regents of the University of California. 3: * All rights reserved. The Berkeley software License Agreement 4: * specifies the terms and conditions for redistribution. 5: * 6: * @(#)signal_.c 5.3 9/11/85 7: * 8: * change the action for a specified signal 9: * 10: * calling sequence: 11: * integer cursig, signal, savsig 12: * external proc 13: * cursig = signal(signum, proc, flag) 14: * where: 15: * 'cursig' will receive the current value of signal(2) 16: * 'signum' must be in the range 0 <= signum <= 32 17: * 18: * If 'flag' is negative, 'proc' must be an external proceedure name. 19: * 20: * If 'flag' is 0 or positive, it will be passed to signal(2) as the 21: * signal action flag. 0 resets the default action; 1 sets 'ignore'. 22: * 'flag' may be the value returned from a previous call to signal. 23: * 24: * This routine arranges to trap user specified signals so that it can 25: * pass the signum fortran style - by address. (boo) 26: */ 27: 28: #include "../libI77/f_errno.h" 29: 30: static int (*dispatch[33])(); 31: int (*signal())(); 32: int sig_trap(); 33: 34: long signal_(sigp, procp, flag) 35: long *sigp, *flag; 36: int (*procp)(); 37: { 38: int (*oldsig)(); 39: int (*oldispatch)(); 40: 41: oldispatch = dispatch[*sigp]; 42: 43: if (*sigp < 0 || *sigp > 32) 44: return(-((long)(errno=F_ERARG))); 45: 46: if (*flag < 0) /* function address passed */ 47: { 48: dispatch[*sigp] = procp; 49: oldsig = signal((int)*sigp, sig_trap); 50: } 51: 52: else /* integer value passed */ 53: oldsig = signal((int)*sigp, (int)*flag); 54: 55: if (oldsig == sig_trap) 56: return((long)oldispatch); 57: return((long)oldsig); 58: } 59: 60: sig_trap(sn) 61: int sn; 62: { 63: long lsn = (long)sn; 64: return((*dispatch[sn])(&lsn)); 65: }