]>
Commit | Line | Data |
---|---|---|
39236c6e A |
1 | /* |
2 | * Copyright (c) 2006, 2010 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
0a7de745 | 5 | * |
39236c6e 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. | |
0a7de745 | 12 | * |
39236c6e A |
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 | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
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. | |
0a7de745 | 20 | * |
39236c6e A |
21 | * @APPLE_LICENSE_HEADER_END@ |
22 | */ | |
23 | ||
24 | ||
0a7de745 A |
25 | #ifndef _SPAWN_H_ |
26 | #define _SPAWN_H_ | |
39236c6e A |
27 | |
28 | /* | |
29 | * [SPN] Support for _POSIX_SPAWN | |
30 | */ | |
31 | ||
3e170ce0 | 32 | #include <sys/cdefs.h> |
39236c6e | 33 | #include <_types.h> |
3e170ce0 | 34 | #include <sys/spawn.h> /* shared types */ |
39236c6e A |
35 | |
36 | #include <Availability.h> | |
37 | ||
38 | /* | |
39 | * [SPN] Inclusion of the <spawn.h> header may make visible symbols defined | |
40 | * in the <sched.h>, <signal.h>, and <sys/types.h> headers. | |
41 | */ | |
42 | #include <sys/_types/_pid_t.h> | |
43 | #include <sys/_types/_sigset_t.h> | |
44 | #include <sys/_types/_mode_t.h> | |
45 | ||
46 | /* | |
47 | * Opaque types for use with posix_spawn() family functions. Internals are | |
48 | * not defined, and should not be accessed directly. Types are defined as | |
49 | * mandated by POSIX. | |
50 | */ | |
51 | typedef void *posix_spawnattr_t; | |
52 | typedef void *posix_spawn_file_actions_t; | |
53 | ||
54 | __BEGIN_DECLS | |
55 | /* | |
56 | * gcc under c99 mode won't compile "[ __restrict]" by itself. As a workaround, | |
57 | * a dummy argument name is added. | |
58 | */ | |
3e170ce0 | 59 | |
0a7de745 A |
60 | int posix_spawn(pid_t * __restrict, const char * __restrict, |
61 | const posix_spawn_file_actions_t *, | |
62 | const posix_spawnattr_t * __restrict, | |
63 | char *const __argv[__restrict], | |
cb323159 | 64 | char *const __envp[__restrict]) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 65 | |
0a7de745 A |
66 | int posix_spawnp(pid_t * __restrict, const char * __restrict, |
67 | const posix_spawn_file_actions_t *, | |
68 | const posix_spawnattr_t * __restrict, | |
69 | char *const __argv[__restrict], | |
cb323159 | 70 | char *const __envp[__restrict]) __API_AVAILABLE(macos(10.5), ios(2.0)); |
3e170ce0 | 71 | |
cb323159 | 72 | int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 73 | |
0a7de745 | 74 | int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, |
cb323159 | 75 | int) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 76 | |
0a7de745 A |
77 | int posix_spawn_file_actions_addopen( |
78 | posix_spawn_file_actions_t * __restrict, int, | |
cb323159 | 79 | const char * __restrict, int, mode_t) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 80 | |
cb323159 | 81 | int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 82 | |
cb323159 | 83 | int posix_spawn_file_actions_init(posix_spawn_file_actions_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 84 | |
cb323159 | 85 | int posix_spawnattr_destroy(posix_spawnattr_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 86 | |
0a7de745 | 87 | int posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict, |
cb323159 | 88 | sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 89 | |
0a7de745 | 90 | int posix_spawnattr_getflags(const posix_spawnattr_t * __restrict, |
cb323159 | 91 | short * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 92 | |
0a7de745 | 93 | int posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict, |
cb323159 | 94 | pid_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 95 | |
0a7de745 | 96 | int posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict, |
cb323159 | 97 | sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 98 | |
cb323159 | 99 | int posix_spawnattr_init(posix_spawnattr_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 100 | |
0a7de745 | 101 | int posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict, |
cb323159 | 102 | const sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 103 | |
cb323159 | 104 | int posix_spawnattr_setflags(posix_spawnattr_t *, short) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 105 | |
cb323159 | 106 | int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 107 | |
0a7de745 | 108 | int posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict, |
cb323159 | 109 | const sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
39236c6e | 110 | |
0a7de745 A |
111 | #if 0 /* _POSIX_PRIORITY_SCHEDULING [PS] : not supported */ |
112 | int posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict, | |
113 | const struct sched_param * __restrict); | |
114 | int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int); | |
115 | int posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict, | |
116 | struct sched_param * __restrict); | |
117 | int posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict, | |
118 | int * __restrict); | |
119 | #endif /* 0 */ | |
39236c6e A |
120 | |
121 | __END_DECLS | |
122 | ||
0a7de745 | 123 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
39236c6e A |
124 | /* |
125 | * Darwin-specific extensions below | |
126 | */ | |
127 | #include <mach/exception_types.h> | |
128 | #include <mach/machine.h> | |
129 | #include <mach/port.h> | |
130 | ||
131 | #include <sys/_types/_size_t.h> | |
132 | ||
133 | __BEGIN_DECLS | |
134 | ||
0a7de745 | 135 | int posix_spawnattr_getbinpref_np(const posix_spawnattr_t * __restrict, |
cb323159 | 136 | size_t, cpu_type_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 137 | |
f427ee49 A |
138 | int posix_spawnattr_getarchpref_np(const posix_spawnattr_t * __restrict, |
139 | size_t, cpu_type_t *__restrict, cpu_subtype_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(10.16), ios(14.0)) __SPI_AVAILABLE(watchos(7.0), tvos(14.0), bridgeos(5.0)); | |
140 | ||
0a7de745 | 141 | int posix_spawnattr_setauditsessionport_np(posix_spawnattr_t * __restrict, |
cb323159 | 142 | mach_port_t) __API_AVAILABLE(macos(10.6), ios(3.2)); |
3e170ce0 | 143 | |
0a7de745 | 144 | int posix_spawnattr_setbinpref_np(posix_spawnattr_t * __restrict, |
cb323159 | 145 | size_t, cpu_type_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 146 | |
f427ee49 A |
147 | int posix_spawnattr_setarchpref_np(posix_spawnattr_t * __restrict, |
148 | size_t, cpu_type_t *__restrict, cpu_subtype_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(10.16), ios(14.0)) __SPI_AVAILABLE(watchos(7.0), tvos(14.0), bridgeos(5.0)); | |
149 | ||
0a7de745 A |
150 | int posix_spawnattr_setexceptionports_np(posix_spawnattr_t * __restrict, |
151 | exception_mask_t, mach_port_t, | |
cb323159 | 152 | exception_behavior_t, thread_state_flavor_t) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 153 | |
0a7de745 | 154 | int posix_spawnattr_setspecialport_np(posix_spawnattr_t * __restrict, |
cb323159 | 155 | mach_port_t, int) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
3e170ce0 | 156 | |
ea3f0419 A |
157 | int posix_spawnattr_setsuidcredport_np(posix_spawnattr_t * __restrict, mach_port_t) __SPI_AVAILABLE(ios(13.0), macos(10.15)); |
158 | ||
f427ee49 A |
159 | int posix_spawnattr_setnosmt_np(const posix_spawnattr_t * __restrict attr) __API_AVAILABLE(macos(10.16)); |
160 | ||
161 | /* | |
162 | * Set CPU Security Mitigation on the spawned process | |
163 | * This attribute affects all threads and is inherited on fork and exec | |
164 | */ | |
165 | int posix_spawnattr_set_csm_np(const posix_spawnattr_t * __restrict attr, uint32_t flags) __API_AVAILABLE(macos(10.16)); | |
166 | /* | |
167 | * flags for CPU Security Mitigation attribute | |
168 | * POSIX_SPAWN_NP_CSM_ALL should be used in most cases, | |
169 | * the individual flags are provided only for performance evaluation etc | |
170 | */ | |
171 | #define POSIX_SPAWN_NP_CSM_ALL 0x0001 | |
172 | #define POSIX_SPAWN_NP_CSM_NOSMT 0x0002 | |
173 | #define POSIX_SPAWN_NP_CSM_TECS 0x0004 | |
174 | ||
0a7de745 | 175 | int posix_spawn_file_actions_addinherit_np(posix_spawn_file_actions_t *, |
cb323159 A |
176 | int) __API_AVAILABLE(macos(10.7), ios(4.3)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); |
177 | ||
178 | int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *, | |
179 | const char * __restrict) __API_AVAILABLE(macos(10.15)) __SPI_AVAILABLE(ios(13.0), tvos(13.0), watchos(6.0), bridgeos(4.0)); | |
180 | ||
181 | int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *, | |
182 | int) __API_AVAILABLE(macos(10.15)) __SPI_AVAILABLE(ios(13.0), tvos(13.0), watchos(6.0), bridgeos(4.0)); | |
39236c6e A |
183 | |
184 | __END_DECLS | |
185 | ||
186 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ | |
0a7de745 | 187 | #endif /* _SPAWN_H_ */ |