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