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