projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed return value; must be from table if signal() returns sig_trap. DLW
[unix-history]
/
usr
/
src
/
usr.bin
/
f77
/
libU77
/
signal_.c
diff --git
a/usr/src/usr.bin/f77/libU77/signal_.c
b/usr/src/usr.bin/f77/libU77/signal_.c
index
f1670b4
..
718f1b1
100644
(file)
--- a/
usr/src/usr.bin/f77/libU77/signal_.c
+++ b/
usr/src/usr.bin/f77/libU77/signal_.c
@@
-1,5
+1,5
@@
/*
/*
-char id_signal[] = "@(#)signal_.c 1.
1
";
+char id_signal[] = "@(#)signal_.c 1.
3
";
*
* change the action for a specified signal
*
*
* change the action for a specified signal
*
@@
-16,23
+16,46
@@
char id_signal[] = "@(#)signal_.c 1.1";
* 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.
* 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"
*/
#include "../libI77/f_errno.h"
-/*** NOTE: the type casts for procp and signal are problematical but work ***/
+int (*dispatch[17])();
int (*signal())();
int (*signal())();
+int sig_trap();
long signal_(sigp, procp, flag)
long *sigp, *flag;
int (*procp)();
{
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 */
if (*sigp < 0 || *sigp > 16)
return(-((long)(errno=F_ERARG)));
if (*flag < 0) /* function address passed */
- return((long)signal((int)*sigp, procp) );
+ {
+ dispatch[*sigp] = procp;
+ oldsig = signal((int)*sigp, sig_trap);
+ }
else /* integer value passed */
else /* integer value passed */
- return((long)signal((int)*sigp, (int)*flag) );
+ 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));
}
}