1 /* Definitions for POSIX spawn interface.
2 Copyright (C) 2000, 2003, 2004, 2008 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 @PRAGMA_SYSTEM_HEADER@
22 /* The include_next requires a split double-inclusion guard. */
24 # @INCLUDE_NEXT@ @NEXT_SPAWN_H@
32 #include <sys/types.h>
38 /* GCC 2.95 and later have "__restrict"; C99 compilers have
39 "restrict", and "configure" may have defined "restrict".
40 Other compilers use __restrict, __restrict__, and _Restrict, and
41 'configure' might #define 'restrict' to those words, so pick a
44 # if 199901L <= __STDC_VERSION__
45 # define _Restrict_ restrict
46 # elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
47 # define _Restrict_ __restrict
52 /* gcc 3.1 and up support the [restrict] syntax. Don't trust
53 sys/cdefs.h's definition of __restrict_arr, though, as it
54 mishandles gcc -ansi -pedantic. */
55 #ifndef _Restrict_arr_
56 # if ((199901L <= __STDC_VERSION__ \
57 || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \
58 && !__STRICT_ANSI__)) \
60 # define _Restrict_arr_ _Restrict_
62 # define _Restrict_arr_
66 /* The definition of GL_LINK_WARNING is copied here. */
69 /* Data structure to contain attributes for thread creation. */
70 #if @REPLACE_POSIX_SPAWN@
71 # define posix_spawnattr_t rpl_posix_spawnattr_t
79 struct sched_param _sp;
85 /* Data structure to contain information about the actions to be
86 performed in the new process with respect to file descriptors. */
87 #if @REPLACE_POSIX_SPAWN@
88 # define posix_spawn_file_actions_t rpl_posix_spawn_file_actions_t
94 struct __spawn_action *_actions;
96 } posix_spawn_file_actions_t;
99 /* Flags to be set in the `posix_spawnattr_t'. */
100 #define POSIX_SPAWN_RESETIDS 0x01
101 #define POSIX_SPAWN_SETPGROUP 0x02
102 #define POSIX_SPAWN_SETSIGDEF 0x04
103 #define POSIX_SPAWN_SETSIGMASK 0x08
104 #define POSIX_SPAWN_SETSCHEDPARAM 0x10
105 #define POSIX_SPAWN_SETSCHEDULER 0x20
106 /* A GNU extension. */
107 #define POSIX_SPAWN_USEVFORK 0x40
115 #if @GNULIB_POSIX_SPAWN@
116 /* Spawn a new process executing PATH with the attributes describes in *ATTRP.
117 Before running the process perform the actions described in FILE-ACTIONS.
119 This function is a possible cancellation points and therefore not
120 marked with __THROW. */
121 # if @REPLACE_POSIX_SPAWN@
122 # define posix_spawn rpl_posix_spawn
124 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
125 extern int posix_spawn (pid_t *_Restrict_ __pid,
126 const char *_Restrict_ __path,
127 const posix_spawn_file_actions_t *_Restrict_ __file_actions,
128 const posix_spawnattr_t *_Restrict_ __attrp,
129 char *const argv[_Restrict_arr_],
130 char *const envp[_Restrict_arr_]);
134 #if @GNULIB_POSIX_SPAWNP@
135 /* Similar to `posix_spawn' but search for FILE in the PATH.
137 This function is a possible cancellation points and therefore not
138 marked with __THROW. */
139 # if @REPLACE_POSIX_SPAWN@
140 # define posix_spawnp rpl_posix_spawnp
142 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
143 extern int posix_spawnp (pid_t *__pid, const char *__file,
144 const posix_spawn_file_actions_t *__file_actions,
145 const posix_spawnattr_t *__attrp,
146 char *const argv[], char *const envp[]);
151 #if @GNULIB_POSIX_SPAWNATTR_INIT@
152 /* Initialize data structure with attributes for `spawn' to default values. */
153 # if @REPLACE_POSIX_SPAWN@
154 # define posix_spawnattr_init rpl_posix_spawnattr_init
156 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
157 extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW;
161 #if @GNULIB_POSIX_SPAWNATTR_DESTROY@
162 /* Free resources associated with ATTR. */
163 # if @REPLACE_POSIX_SPAWN@
164 # define posix_spawnattr_destroy rpl_posix_spawnattr_destroy
166 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
167 extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW;
171 #if @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@
172 /* Store signal mask for signals with default handling from ATTR in
174 # if @REPLACE_POSIX_SPAWN@
175 # define posix_spawnattr_getsigdefault rpl_posix_spawnattr_getsigdefault
177 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
178 extern int posix_spawnattr_getsigdefault (const posix_spawnattr_t *_Restrict_ __attr,
179 sigset_t *_Restrict_ __sigdefault)
184 #if @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@
185 /* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */
186 # if @REPLACE_POSIX_SPAWN@
187 # define posix_spawnattr_setsigdefault rpl_posix_spawnattr_setsigdefault
189 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
190 extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *_Restrict_ __attr,
191 const sigset_t *_Restrict_ __sigdefault)
196 #if @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@
197 /* Store signal mask for the new process from ATTR in SIGMASK. */
198 # if @REPLACE_POSIX_SPAWN@
199 # define posix_spawnattr_getsigmask rpl_posix_spawnattr_getsigmask
201 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
202 extern int posix_spawnattr_getsigmask (const posix_spawnattr_t *_Restrict_ __attr,
203 sigset_t *_Restrict_ __sigmask) __THROW;
207 #if @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@
208 /* Set signal mask for the new process in ATTR to SIGMASK. */
209 # if @REPLACE_POSIX_SPAWN@
210 # define posix_spawnattr_setsigmask rpl_posix_spawnattr_setsigmask
212 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
213 extern int posix_spawnattr_setsigmask (posix_spawnattr_t *_Restrict_ __attr,
214 const sigset_t *_Restrict_ __sigmask)
219 #if @GNULIB_POSIX_SPAWNATTR_GETFLAGS@
220 /* Get flag word from the attribute structure. */
221 # if @REPLACE_POSIX_SPAWN@
222 # define posix_spawnattr_getflags rpl_posix_spawnattr_getflags
224 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
225 extern int posix_spawnattr_getflags (const posix_spawnattr_t *_Restrict_ __attr,
226 short int *_Restrict_ __flags) __THROW;
230 #if @GNULIB_POSIX_SPAWNATTR_SETFLAGS@
231 /* Store flags in the attribute structure. */
232 # if @REPLACE_POSIX_SPAWN@
233 # define posix_spawnattr_setflags rpl_posix_spawnattr_setflags
235 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
236 extern int posix_spawnattr_setflags (posix_spawnattr_t *__attr,
237 short int __flags) __THROW;
241 #if @GNULIB_POSIX_SPAWNATTR_GETPGROUP@
242 /* Get process group ID from the attribute structure. */
243 # if @REPLACE_POSIX_SPAWN@
244 # define posix_spawnattr_getpgroup rpl_posix_spawnattr_getpgroup
246 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
247 extern int posix_spawnattr_getpgroup (const posix_spawnattr_t *_Restrict_ __attr,
248 pid_t *_Restrict_ __pgroup)
253 #if @GNULIB_POSIX_SPAWNATTR_SETPGROUP@
254 /* Store process group ID in the attribute structure. */
255 # if @REPLACE_POSIX_SPAWN@
256 # define posix_spawnattr_setpgroup rpl_posix_spawnattr_setpgroup
258 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
259 extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr,
260 pid_t __pgroup) __THROW;
264 #if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@
265 /* Get scheduling policy from the attribute structure. */
266 # if @REPLACE_POSIX_SPAWN@
267 # define posix_spawnattr_getschedpolicy rpl_posix_spawnattr_getschedpolicy
269 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
270 extern int posix_spawnattr_getschedpolicy (const posix_spawnattr_t *_Restrict_ __attr,
271 int *_Restrict_ __schedpolicy)
276 #if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@
277 /* Store scheduling policy in the attribute structure. */
278 # if @REPLACE_POSIX_SPAWN@
279 # define posix_spawnattr_setschedpolicy rpl_posix_spawnattr_setschedpolicy
281 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
282 extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
283 int __schedpolicy) __THROW;
287 #if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@
288 /* Get scheduling parameters from the attribute structure. */
289 # if @REPLACE_POSIX_SPAWN@
290 # define posix_spawnattr_getschedparam rpl_posix_spawnattr_getschedparam
292 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
293 extern int posix_spawnattr_getschedparam (const posix_spawnattr_t *_Restrict_ __attr,
294 struct sched_param *_Restrict_ __schedparam) __THROW;
298 #if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@
299 /* Store scheduling parameters in the attribute structure. */
300 # if @REPLACE_POSIX_SPAWN@
301 # define posix_spawnattr_setschedparam rpl_posix_spawnattr_setschedparam
303 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
304 extern int posix_spawnattr_setschedparam (posix_spawnattr_t *_Restrict_ __attr,
305 const struct sched_param *_Restrict_ __schedparam) __THROW;
310 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@
311 /* Initialize data structure for file attribute for `spawn' call. */
312 # if @REPLACE_POSIX_SPAWN@
313 # define posix_spawn_file_actions_init rpl_posix_spawn_file_actions_init
315 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
316 extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *__file_actions) __THROW;
320 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@
321 /* Free resources associated with FILE-ACTIONS. */
322 # if @REPLACE_POSIX_SPAWN@
323 # define posix_spawn_file_actions_destroy rpl_posix_spawn_file_actions_destroy
325 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
326 extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *__file_actions) __THROW;
330 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@
331 /* Add an action to FILE-ACTIONS which tells the implementation to call
332 `open' for the given file during the `spawn' call. */
333 # if @REPLACE_POSIX_SPAWN@
334 # define posix_spawn_file_actions_addopen rpl_posix_spawn_file_actions_addopen
336 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
337 extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *_Restrict_ __file_actions,
339 const char *_Restrict_ __path,
340 int __oflag, mode_t __mode)
345 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@
346 /* Add an action to FILE-ACTIONS which tells the implementation to call
347 `close' for the given file descriptor during the `spawn' call. */
348 # if @REPLACE_POSIX_SPAWN@
349 # define posix_spawn_file_actions_addclose rpl_posix_spawn_file_actions_addclose
351 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
352 extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *__file_actions,
358 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@
359 /* Add an action to FILE-ACTIONS which tells the implementation to call
360 `dup2' for the given file descriptors during the `spawn' call. */
361 # if @REPLACE_POSIX_SPAWN@
362 # define posix_spawn_file_actions_adddup2 rpl_posix_spawn_file_actions_adddup2
364 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
365 extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *__file_actions,
366 int __fd, int __newfd) __THROW;
376 #endif /* _GL_SPAWN_H */
377 #endif /* _GL_SPAWN_H */