add -f on mv for Version
[unix-history] / usr / src / usr.bin / f77 / libF77 / signal_.c
CommitLineData
45fbac79 1/*
42a118aa
RE
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.
45fbac79 5 *
cccceb90 6 * @(#)signal_.c 5.3 %G%
a2b867fb 7 *
45fbac79
DW
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)
cccceb90 16 * 'signum' must be in the range 0 <= signum <= 32
45fbac79
DW
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
cccceb90 30static int (*dispatch[33])();
45fbac79
DW
31int (*signal())();
32int sig_trap();
33
34long signal_(sigp, procp, flag)
35long *sigp, *flag;
36int (*procp)();
37{
38 int (*oldsig)();
39 int (*oldispatch)();
40
41 oldispatch = dispatch[*sigp];
42
cccceb90 43 if (*sigp < 0 || *sigp > 32)
45fbac79
DW
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
60sig_trap(sn)
61int sn;
62{
63 long lsn = (long)sn;
64 return((*dispatch[sn])(&lsn));
65}