]>
git.saurik.com Git - apple/libc.git/blob - sys.subproj/sigaction.c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved
28 #include <sys/syscall.h>
30 #include <sys/signal.h>
34 * Intercept the sigaction syscall and use our signal trampoline
35 * as the signal handler instead. The code here is derived
36 * from sigvec in sys/kern_sig.c.
39 extern void (*sigcatch
[NSIG
])();
40 #if defined(__DYNAMIC__)
41 extern int __in_sigtramp
;
45 sigaction__ (sig
, nsv
, osv
, bind
)
47 register struct sigaction
*nsv
, *osv
;
52 extern void _sigtramp();
54 if (sig
<= 0 || sig
>= NSIG
|| sig
== SIGKILL
|| sig
== SIGSTOP
) {
58 prevsig
= sigcatch
[sig
];
60 sigcatch
[sig
] = nsv
->sa_handler
;
61 vec
= *nsv
; nsv
= &vec
;
62 if (nsv
->sa_handler
!= (void (*)())SIG_DFL
&& nsv
->sa_handler
!= (void (*)())SIG_IGN
) {
63 nsv
->sa_handler
= _sigtramp
;
65 if (bind
&& (__in_sigtramp
== 0)) // XXX
66 _dyld_bind_fully_image_containing_address(sigcatch
[sig
]);
70 if (syscall (SYS_sigaction
, sig
, nsv
, osv
) < 0) {
71 sigcatch
[sig
] = prevsig
;
75 osv
->sa_handler
= prevsig
;
81 sigaction (sig
, nsv
, osv
)
83 register const struct sigaction
*nsv
;
84 register struct sigaction
*osv
;
86 return sigaction__(sig
, nsv
, osv
, 1);
93 _sigaction_nobind (sig
, nsv
, osv
)
95 register const struct sigaction
*nsv
;
96 register struct sigaction
*osv
;
98 return sigaction__(sig
, nsv
, osv
, 0);