]> git.saurik.com Git - apple/libc.git/blame - sys/sigaction.c
Libc-1272.200.26.tar.gz
[apple/libc.git] / sys / sigaction.c
CommitLineData
e9ce8d39 1/*
70ad1dc8 2 * Copyright (c) 1999-2017 Apple Computer, Inc. All rights reserved.
e9ce8d39
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
734aad71
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
e9ce8d39
A
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
734aad71
A
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
e9ce8d39
A
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
e9ce8d39 23
5f125488
A
24#include <CrashReporterClient.h>
25#include <stdlib.h>
26#include <stdio.h>
9385eb3d 27#include <unistd.h>
e9ce8d39
A
28#include <signal.h>
29#include <sys/signal.h>
30#include <errno.h>
31
70ad1dc8
A
32#pragma clang diagnostic push
33#pragma clang diagnostic ignored "-Wstrict-prototypes"
34
35extern int __platform_sigaction (int sig,
36 const struct sigaction * __restrict nsv,
37 struct sigaction * __restrict osv);
e9ce8d39 38
3d9156a7 39int
70ad1dc8
A
40sigaction (int sig, const struct sigaction * __restrict nsv,
41 struct sigaction * __restrict osv)
e9ce8d39 42{
70ad1dc8 43 int ret = __platform_sigaction(sig, nsv, osv);
5f125488
A
44#ifdef FEATURE_SIGNAL_RESTRICTION
45 // Note: The "sig != 0" here is to force the compiler to maintain that "sig"
46 // is live, and in a register, after __sigaction so it is visible in the
47 // crashing register state.
48 if (ret == -1 && errno == ENOTSUP && sig != 0) {
49 CRSetCrashLogMessage("sigaction on fatal signals is not supported");
50 __builtin_trap();
51 }
52#endif
53 return ret;
e9ce8d39
A
54}
55
e9ce8d39
A
56// XXX
57#ifdef __DYNAMIC__
58
59int
60_sigaction_nobind (sig, nsv, osv)
61 int sig;
62 register const struct sigaction *nsv;
63 register struct sigaction *osv;
64{
3d9156a7 65 return sigaction(sig, nsv, osv);
e9ce8d39
A
66}
67#endif
68
70ad1dc8 69#pragma clang diagnostic pop