2 * Copyright (c) 2006, 2010 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
29 * [SPN] Support for _POSIX_SPAWN
32 #include <sys/cdefs.h>
34 #include <sys/spawn.h> /* shared types */
36 #include <Availability.h>
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.
42 #include <sys/_types/_pid_t.h>
43 #include <sys/_types/_sigset_t.h>
44 #include <sys/_types/_mode_t.h>
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
51 typedef void *posix_spawnattr_t
;
52 typedef void *posix_spawn_file_actions_t
;
56 * gcc under c99 mode won't compile "[ __restrict]" by itself. As a workaround,
57 * a dummy argument name is added.
59 int posix_spawn(pid_t
* __restrict
, const char * __restrict
,
60 const posix_spawn_file_actions_t
*,
61 const posix_spawnattr_t
* __restrict
,
62 char *const __argv
[ __restrict
],
63 char *const __envp
[ __restrict
]) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
64 int posix_spawnp(pid_t
* __restrict
, const char * __restrict
,
65 const posix_spawn_file_actions_t
*,
66 const posix_spawnattr_t
* __restrict
,
67 char *const __argv
[ __restrict
],
68 char *const __envp
[ __restrict
]) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
69 int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t
*, int) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
70 int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t
*, int,
71 int) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
72 int posix_spawn_file_actions_addopen(
73 posix_spawn_file_actions_t
* __restrict
, int,
74 const char * __restrict
, int, mode_t
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
75 int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t
*) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
76 int posix_spawn_file_actions_init(posix_spawn_file_actions_t
*) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
77 int posix_spawnattr_destroy(posix_spawnattr_t
*) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
78 int posix_spawnattr_getsigdefault(const posix_spawnattr_t
* __restrict
,
79 sigset_t
* __restrict
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
80 int posix_spawnattr_getflags(const posix_spawnattr_t
* __restrict
,
81 short * __restrict
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
82 int posix_spawnattr_getpgroup(const posix_spawnattr_t
* __restrict
,
83 pid_t
* __restrict
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
84 int posix_spawnattr_getsigmask(const posix_spawnattr_t
* __restrict
,
85 sigset_t
* __restrict
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
86 int posix_spawnattr_init(posix_spawnattr_t
*) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
87 int posix_spawnattr_setsigdefault(posix_spawnattr_t
* __restrict
,
88 const sigset_t
* __restrict
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
89 int posix_spawnattr_setflags(posix_spawnattr_t
*, short) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
90 int posix_spawnattr_setpgroup(posix_spawnattr_t
*, pid_t
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
91 int posix_spawnattr_setsigmask(posix_spawnattr_t
* __restrict
,
92 const sigset_t
* __restrict
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
94 #if 0 /* _POSIX_PRIORITY_SCHEDULING [PS] : not supported */
95 int posix_spawnattr_setschedparam(posix_spawnattr_t
* __restrict
,
96 const struct sched_param
* __restrict
);
97 int posix_spawnattr_setschedpolicy(posix_spawnattr_t
*, int);
98 int posix_spawnattr_getschedparam(const posix_spawnattr_t
* __restrict
,
99 struct sched_param
* __restrict
);
100 int posix_spawnattr_getschedpolicy(const posix_spawnattr_t
* __restrict
,
106 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
108 * Darwin-specific extensions below
110 #include <mach/exception_types.h>
111 #include <mach/machine.h>
112 #include <mach/port.h>
114 #include <sys/_types/_size_t.h>
118 int posix_spawnattr_getbinpref_np(const posix_spawnattr_t
* __restrict
,
119 size_t, cpu_type_t
*__restrict
, size_t *__restrict
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
120 int posix_spawnattr_setauditsessionport_np(posix_spawnattr_t
*__restrict
,
121 mach_port_t
) __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_3_2
);
122 int posix_spawnattr_setbinpref_np(posix_spawnattr_t
* __restrict
,
123 size_t, cpu_type_t
*__restrict
, size_t *__restrict
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
124 int posix_spawnattr_setexceptionports_np(posix_spawnattr_t
*__restrict
,
125 exception_mask_t
, mach_port_t
,
126 exception_behavior_t
, thread_state_flavor_t
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
127 int posix_spawnattr_setspecialport_np(posix_spawnattr_t
*__restrict
,
128 mach_port_t
, int) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
129 int posix_spawn_file_actions_addinherit_np(posix_spawn_file_actions_t
*,
130 int) __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_4_3
);
134 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
135 #endif /* _SPAWN_H_ */