the window strings is NOT quoted at this point; other cleanups
[unix-history] / usr / src / lib / libc / gen / signal.c
index e8ff3f8..cf78d99 100644 (file)
@@ -1,25 +1,36 @@
-/*     signal.c        4.2     85/01/15        */
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)signal.c   5.2 (Berkeley) %G%";
+#endif LIBC_SCCS and not lint
+
 /*
  * Almost backwards compatible signal.
 /*
  * Almost backwards compatible signal.
- *     int (*signal(s, a))() int s, (*a)();
  */
  */
-#include <syscall.h>
-#include "DEFS.h"
+#include <signal.h>
+
+int (*
+signal(s, a))()
+       int s, (*a)();
+{
+       struct sigvec osv, sv;
+       static int mask[NSIG];
+       static int flags[NSIG];
 
 
-ENTRY(signal, 0)
-       subl2   $24,sp                  # struct sigvec osv, sv;
-       movl    8(ap),-24(fp)           # sv.sv_handler = a;
-       clrq    -20(fp)                 # sv.sv_mask = sv.sv_onstack = 0;
-       pushal  -12(fp)                 # &osv
-       pushal  -24(fp)                 # &sv
-       pushl   4(ap)                   # s
-       moval   -4(sp),ap
-       chmk    $SYS_sigvec             # sigvec(s, &sv, &osv)
-       jcs     err
-       movl    -12(fp),r0              # return osv.sv_handler;
-       ret
-err:
-       .globl  _errno
-       movl    r0,_errno
-       mnegl   $1,r0
-       ret
+       sv.sv_handler = a;
+       sv.sv_mask = mask[s];
+       sv.sv_flags = flags[s];
+       if (sigvec(s, &sv, &osv) < 0)
+               return (BADSIG);
+       if (sv.sv_mask != osv.sv_mask || sv.sv_flags != osv.sv_flags) {
+               mask[s] = sv.sv_mask = osv.sv_mask;
+               flags[s] = sv.sv_flags = osv.sv_flags;
+               if (sigvec(s, &sv, 0) < 0)
+                       return (BADSIG);
+       }
+       return (osv.sv_handler);
+}