From: David Wasley Date: Sat, 22 Jan 1983 03:19:18 +0000 (-0800) Subject: date and time created 83/01/21 11:19:18 by dlw X-Git-Tag: BSD-4_1c_2-Snapshot-Development~854 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/45fbac7905110e8d6ccdf6d1853c58339b1f4d41 date and time created 83/01/21 11:19:18 by dlw SCCS-vsn: usr.bin/f77/libF77/signal_.c 1.1 --- diff --git a/usr/src/usr.bin/f77/libF77/signal_.c b/usr/src/usr.bin/f77/libF77/signal_.c new file mode 100644 index 0000000000..43331ac144 --- /dev/null +++ b/usr/src/usr.bin/f77/libF77/signal_.c @@ -0,0 +1,61 @@ +/* + * "@(#)signal_.c 1.1" + * + * change the action for a specified signal + * + * calling sequence: + * integer cursig, signal, savsig + * external proc + * cursig = signal(signum, proc, flag) + * where: + * 'cursig' will receive the current value of signal(2) + * 'signum' must be in the range 0 <= signum <= 16 + * + * If 'flag' is negative, 'proc' must be an external proceedure name. + * + * If 'flag' is 0 or positive, it will be passed to signal(2) as the + * signal action flag. 0 resets the default action; 1 sets 'ignore'. + * 'flag' may be the value returned from a previous call to signal. + * + * This routine arranges to trap user specified signals so that it can + * pass the signum fortran style - by address. (boo) + */ + +#include "../libI77/f_errno.h" + +static int (*dispatch[17])(); +int (*signal())(); +int sig_trap(); + +long signal_(sigp, procp, flag) +long *sigp, *flag; +int (*procp)(); +{ + int (*oldsig)(); + int (*oldispatch)(); + + oldispatch = dispatch[*sigp]; + + if (*sigp < 0 || *sigp > 16) + return(-((long)(errno=F_ERARG))); + + if (*flag < 0) /* function address passed */ + { + dispatch[*sigp] = procp; + oldsig = signal((int)*sigp, sig_trap); + } + + else /* integer value passed */ + oldsig = signal((int)*sigp, (int)*flag); + + if (oldsig == sig_trap) + return((long)oldispatch); + return((long)oldsig); +} + +sig_trap(sn) +int sn; +{ + long lsn = (long)sn; + return((*dispatch[sn])(&lsn)); +}