1*bbb1b6f9SApple OSS Distributions /* 2*bbb1b6f9SApple OSS Distributions * Copyright (c) 2006, 2010 Apple Inc. All rights reserved. 3*bbb1b6f9SApple OSS Distributions * 4*bbb1b6f9SApple OSS Distributions * @APPLE_LICENSE_HEADER_START@ 5*bbb1b6f9SApple OSS Distributions * 6*bbb1b6f9SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*bbb1b6f9SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*bbb1b6f9SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*bbb1b6f9SApple OSS Distributions * compliance with the License. Please obtain a copy of the License at 10*bbb1b6f9SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this 11*bbb1b6f9SApple OSS Distributions * file. 12*bbb1b6f9SApple OSS Distributions * 13*bbb1b6f9SApple OSS Distributions * The Original Code and all software distributed under the License are 14*bbb1b6f9SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15*bbb1b6f9SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16*bbb1b6f9SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17*bbb1b6f9SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18*bbb1b6f9SApple OSS Distributions * Please see the License for the specific language governing rights and 19*bbb1b6f9SApple OSS Distributions * limitations under the License. 20*bbb1b6f9SApple OSS Distributions * 21*bbb1b6f9SApple OSS Distributions * @APPLE_LICENSE_HEADER_END@ 22*bbb1b6f9SApple OSS Distributions */ 23*bbb1b6f9SApple OSS Distributions 24*bbb1b6f9SApple OSS Distributions 25*bbb1b6f9SApple OSS Distributions #ifndef _SPAWN_H_ 26*bbb1b6f9SApple OSS Distributions #define _SPAWN_H_ 27*bbb1b6f9SApple OSS Distributions 28*bbb1b6f9SApple OSS Distributions /* 29*bbb1b6f9SApple OSS Distributions * [SPN] Support for _POSIX_SPAWN 30*bbb1b6f9SApple OSS Distributions */ 31*bbb1b6f9SApple OSS Distributions 32*bbb1b6f9SApple OSS Distributions #include <sys/cdefs.h> 33*bbb1b6f9SApple OSS Distributions #include <_types.h> 34*bbb1b6f9SApple OSS Distributions #include <sys/spawn.h> /* shared types */ 35*bbb1b6f9SApple OSS Distributions 36*bbb1b6f9SApple OSS Distributions #include <Availability.h> 37*bbb1b6f9SApple OSS Distributions 38*bbb1b6f9SApple OSS Distributions /* 39*bbb1b6f9SApple OSS Distributions * [SPN] Inclusion of the <spawn.h> header may make visible symbols defined 40*bbb1b6f9SApple OSS Distributions * in the <sched.h>, <signal.h>, and <sys/types.h> headers. 41*bbb1b6f9SApple OSS Distributions */ 42*bbb1b6f9SApple OSS Distributions #include <sys/_types/_pid_t.h> 43*bbb1b6f9SApple OSS Distributions #include <sys/_types/_sigset_t.h> 44*bbb1b6f9SApple OSS Distributions #include <sys/_types/_mode_t.h> 45*bbb1b6f9SApple OSS Distributions 46*bbb1b6f9SApple OSS Distributions /* 47*bbb1b6f9SApple OSS Distributions * Opaque types for use with posix_spawn() family functions. Internals are 48*bbb1b6f9SApple OSS Distributions * not defined, and should not be accessed directly. Types are defined as 49*bbb1b6f9SApple OSS Distributions * mandated by POSIX. 50*bbb1b6f9SApple OSS Distributions */ 51*bbb1b6f9SApple OSS Distributions typedef void *posix_spawnattr_t; 52*bbb1b6f9SApple OSS Distributions typedef void *posix_spawn_file_actions_t; 53*bbb1b6f9SApple OSS Distributions 54*bbb1b6f9SApple OSS Distributions __BEGIN_DECLS 55*bbb1b6f9SApple OSS Distributions /* 56*bbb1b6f9SApple OSS Distributions * gcc under c99 mode won't compile "[ __restrict]" by itself. As a workaround, 57*bbb1b6f9SApple OSS Distributions * a dummy argument name is added. 58*bbb1b6f9SApple OSS Distributions */ 59*bbb1b6f9SApple OSS Distributions 60*bbb1b6f9SApple OSS Distributions int posix_spawn(pid_t * __restrict, const char * __restrict, 61*bbb1b6f9SApple OSS Distributions const posix_spawn_file_actions_t *, 62*bbb1b6f9SApple OSS Distributions const posix_spawnattr_t * __restrict, 63*bbb1b6f9SApple OSS Distributions char *const __argv[__restrict], 64*bbb1b6f9SApple OSS Distributions char *const __envp[__restrict]) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); 65*bbb1b6f9SApple OSS Distributions 66*bbb1b6f9SApple OSS Distributions int posix_spawnp(pid_t * __restrict, const char * __restrict, 67*bbb1b6f9SApple OSS Distributions const posix_spawn_file_actions_t *, 68*bbb1b6f9SApple OSS Distributions const posix_spawnattr_t * __restrict, 69*bbb1b6f9SApple OSS Distributions char *const __argv[__restrict], 70*bbb1b6f9SApple OSS Distributions char *const __envp[__restrict]) __API_AVAILABLE(macos(10.5), ios(2.0)); 71*bbb1b6f9SApple OSS Distributions 72*bbb1b6f9SApple OSS Distributions int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t *, 73*bbb1b6f9SApple OSS Distributions const char * __restrict) __API_AVAILABLE(macos(16.0)) __SPI_AVAILABLE(ios(19.0), tvos(19.0), watchos(12.0), visionos(3.0), bridgeos(10.0)); 74*bbb1b6f9SApple OSS Distributions 75*bbb1b6f9SApple OSS Distributions int posix_spawn_file_actions_addfchdir(posix_spawn_file_actions_t *, 76*bbb1b6f9SApple OSS Distributions int) __API_AVAILABLE(macos(16.0)) __SPI_AVAILABLE(ios(19.0), tvos(19.0), watchos(12.0), visionos(3.0), bridgeos(10.0)); 77*bbb1b6f9SApple OSS Distributions 78*bbb1b6f9SApple OSS Distributions 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)); 79*bbb1b6f9SApple OSS Distributions 80*bbb1b6f9SApple OSS Distributions int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, 81*bbb1b6f9SApple OSS Distributions int) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); 82*bbb1b6f9SApple OSS Distributions 83*bbb1b6f9SApple OSS Distributions int posix_spawn_file_actions_addopen( 84*bbb1b6f9SApple OSS Distributions posix_spawn_file_actions_t * __restrict, int, 85*bbb1b6f9SApple OSS Distributions 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)); 86*bbb1b6f9SApple OSS Distributions 87*bbb1b6f9SApple OSS Distributions 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)); 88*bbb1b6f9SApple OSS Distributions 89*bbb1b6f9SApple OSS Distributions 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)); 90*bbb1b6f9SApple OSS Distributions 91*bbb1b6f9SApple OSS Distributions 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)); 92*bbb1b6f9SApple OSS Distributions 93*bbb1b6f9SApple OSS Distributions int posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict, 94*bbb1b6f9SApple OSS Distributions sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); 95*bbb1b6f9SApple OSS Distributions 96*bbb1b6f9SApple OSS Distributions int posix_spawnattr_getflags(const posix_spawnattr_t * __restrict, 97*bbb1b6f9SApple OSS Distributions short * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); 98*bbb1b6f9SApple OSS Distributions 99*bbb1b6f9SApple OSS Distributions int posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict, 100*bbb1b6f9SApple OSS Distributions pid_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); 101*bbb1b6f9SApple OSS Distributions 102*bbb1b6f9SApple OSS Distributions int posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict, 103*bbb1b6f9SApple OSS Distributions sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); 104*bbb1b6f9SApple OSS Distributions 105*bbb1b6f9SApple OSS Distributions 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)); 106*bbb1b6f9SApple OSS Distributions 107*bbb1b6f9SApple OSS Distributions int posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict, 108*bbb1b6f9SApple OSS Distributions const sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); 109*bbb1b6f9SApple OSS Distributions 110*bbb1b6f9SApple OSS Distributions 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)); 111*bbb1b6f9SApple OSS Distributions 112*bbb1b6f9SApple OSS Distributions 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)); 113*bbb1b6f9SApple OSS Distributions 114*bbb1b6f9SApple OSS Distributions int posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict, 115*bbb1b6f9SApple OSS Distributions const sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); 116*bbb1b6f9SApple OSS Distributions 117*bbb1b6f9SApple OSS Distributions #if 0 /* _POSIX_PRIORITY_SCHEDULING [PS] : not supported */ 118*bbb1b6f9SApple OSS Distributions int posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict, 119*bbb1b6f9SApple OSS Distributions const struct sched_param * __restrict); 120*bbb1b6f9SApple OSS Distributions int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int); 121*bbb1b6f9SApple OSS Distributions int posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict, 122*bbb1b6f9SApple OSS Distributions struct sched_param * __restrict); 123*bbb1b6f9SApple OSS Distributions int posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict, 124*bbb1b6f9SApple OSS Distributions int * __restrict); 125*bbb1b6f9SApple OSS Distributions #endif /* 0 */ 126*bbb1b6f9SApple OSS Distributions 127*bbb1b6f9SApple OSS Distributions __END_DECLS 128*bbb1b6f9SApple OSS Distributions 129*bbb1b6f9SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 130*bbb1b6f9SApple OSS Distributions /* 131*bbb1b6f9SApple OSS Distributions * Darwin-specific extensions below 132*bbb1b6f9SApple OSS Distributions */ 133*bbb1b6f9SApple OSS Distributions #include <mach/exception_types.h> 134*bbb1b6f9SApple OSS Distributions #include <mach/machine.h> 135*bbb1b6f9SApple OSS Distributions #include <mach/port.h> 136*bbb1b6f9SApple OSS Distributions 137*bbb1b6f9SApple OSS Distributions #include <sys/_types/_size_t.h> 138*bbb1b6f9SApple OSS Distributions 139*bbb1b6f9SApple OSS Distributions __BEGIN_DECLS 140*bbb1b6f9SApple OSS Distributions 141*bbb1b6f9SApple OSS Distributions int posix_spawnattr_getbinpref_np(const posix_spawnattr_t * __restrict, 142*bbb1b6f9SApple OSS Distributions 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)); 143*bbb1b6f9SApple OSS Distributions 144*bbb1b6f9SApple OSS Distributions int posix_spawnattr_getarchpref_np(const posix_spawnattr_t * __restrict, 145*bbb1b6f9SApple OSS Distributions 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)); 146*bbb1b6f9SApple OSS Distributions 147*bbb1b6f9SApple OSS Distributions int posix_spawnattr_setauditsessionport_np(posix_spawnattr_t * __restrict, 148*bbb1b6f9SApple OSS Distributions mach_port_t) __API_AVAILABLE(macos(10.6), ios(3.2)); 149*bbb1b6f9SApple OSS Distributions 150*bbb1b6f9SApple OSS Distributions int posix_spawnattr_setbinpref_np(posix_spawnattr_t * __restrict, 151*bbb1b6f9SApple OSS Distributions 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)); 152*bbb1b6f9SApple OSS Distributions 153*bbb1b6f9SApple OSS Distributions int posix_spawnattr_setarchpref_np(posix_spawnattr_t * __restrict, 154*bbb1b6f9SApple OSS Distributions 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)); 155*bbb1b6f9SApple OSS Distributions 156*bbb1b6f9SApple OSS Distributions int posix_spawnattr_setexceptionports_np(posix_spawnattr_t * __restrict, 157*bbb1b6f9SApple OSS Distributions exception_mask_t, mach_port_t, 158*bbb1b6f9SApple OSS Distributions 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)); 159*bbb1b6f9SApple OSS Distributions 160*bbb1b6f9SApple OSS Distributions int posix_spawnattr_setspecialport_np(posix_spawnattr_t * __restrict, 161*bbb1b6f9SApple OSS Distributions mach_port_t, int) __API_AVAILABLE(macos(10.5), ios(2.0)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); 162*bbb1b6f9SApple OSS Distributions 163*bbb1b6f9SApple OSS Distributions int posix_spawnattr_setnosmt_np(const posix_spawnattr_t * __restrict attr) __API_AVAILABLE(macos(10.16)); 164*bbb1b6f9SApple OSS Distributions 165*bbb1b6f9SApple OSS Distributions /* 166*bbb1b6f9SApple OSS Distributions * Set CPU Security Mitigation on the spawned process 167*bbb1b6f9SApple OSS Distributions * This attribute affects all threads and is inherited on fork and exec 168*bbb1b6f9SApple OSS Distributions */ 169*bbb1b6f9SApple OSS Distributions int posix_spawnattr_set_csm_np(const posix_spawnattr_t * __restrict attr, uint32_t flags) __API_AVAILABLE(macos(10.16)); 170*bbb1b6f9SApple OSS Distributions /* 171*bbb1b6f9SApple OSS Distributions * flags for CPU Security Mitigation attribute 172*bbb1b6f9SApple OSS Distributions * POSIX_SPAWN_NP_CSM_ALL should be used in most cases, 173*bbb1b6f9SApple OSS Distributions * the individual flags are provided only for performance evaluation etc 174*bbb1b6f9SApple OSS Distributions */ 175*bbb1b6f9SApple OSS Distributions #define POSIX_SPAWN_NP_CSM_ALL 0x0001 176*bbb1b6f9SApple OSS Distributions #define POSIX_SPAWN_NP_CSM_NOSMT 0x0002 177*bbb1b6f9SApple OSS Distributions #define POSIX_SPAWN_NP_CSM_TECS 0x0004 178*bbb1b6f9SApple OSS Distributions 179*bbb1b6f9SApple OSS Distributions int posix_spawn_file_actions_addinherit_np(posix_spawn_file_actions_t *, 180*bbb1b6f9SApple OSS Distributions int) __API_AVAILABLE(macos(10.7), ios(4.3)) __SPI_AVAILABLE(watchos(2.0), tvos(9.0), bridgeos(1.0)); 181*bbb1b6f9SApple OSS Distributions 182*bbb1b6f9SApple OSS Distributions int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *, 183*bbb1b6f9SApple OSS Distributions const char * __restrict) __API_DEPRECATED("posix_spawn_file_actions_addchdir(3) has replaced posix_spawn_file_actions_addchdir_np(3)", macos(10.15, 16.0)) __SPI_DEPRECATED("posix_spawn_file_actions_addchdir(3) has replaced posix_spawn_file_actions_addchdir_np(3)", ios(13.0, 19.0), tvos(13.0, 19.0), watchos(6.0, 12.0), visionos(1.0, 3.0), bridgeos(4.0, 10.0)); 184*bbb1b6f9SApple OSS Distributions 185*bbb1b6f9SApple OSS Distributions int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *, 186*bbb1b6f9SApple OSS Distributions int) __API_DEPRECATED("posix_spawn_file_actions_addfchdir(3) has replaced posix_spawn_file_actions_addfchdir_np(3)", macos(10.15, 16.0)) __SPI_DEPRECATED("posix_spawn_file_actions_addfchdir(3) has replaced posix_spawn_file_actions_addfchdir_np(3)", ios(13.0, 19.0), tvos(13.0, 19.0), watchos(6.0, 12.0), visionos(1.0, 3.0), bridgeos(4.0, 10.0)); 187*bbb1b6f9SApple OSS Distributions 188*bbb1b6f9SApple OSS Distributions __END_DECLS 189*bbb1b6f9SApple OSS Distributions 190*bbb1b6f9SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 191*bbb1b6f9SApple OSS Distributions #endif /* _SPAWN_H_ */ 192