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 #undef POSIX_SPAWN_RESETIDS
101 #define POSIX_SPAWN_RESETIDS 0x01
102 #undef POSIX_SPAWN_SETPGROUP
103 #define POSIX_SPAWN_SETPGROUP 0x02
104 #undef POSIX_SPAWN_SETSIGDEF
105 #define POSIX_SPAWN_SETSIGDEF 0x04
106 #undef POSIX_SPAWN_SETSIGMASK
107 #define POSIX_SPAWN_SETSIGMASK 0x08
108 #undef POSIX_SPAWN_SETSCHEDPARAM
109 #define POSIX_SPAWN_SETSCHEDPARAM 0x10
110 #undef POSIX_SPAWN_SETSCHEDULER
111 #define POSIX_SPAWN_SETSCHEDULER 0x20
112 /* A GNU extension. */
113 #undef POSIX_SPAWN_USEVFORK
114 #define POSIX_SPAWN_USEVFORK 0x40
122 #if @GNULIB_POSIX_SPAWN@
123 /* Spawn a new process executing PATH with the attributes describes in *ATTRP.
124 Before running the process perform the actions described in FILE-ACTIONS.
126 This function is a possible cancellation points and therefore not
127 marked with __THROW. */
128 # if @REPLACE_POSIX_SPAWN@
129 # define posix_spawn rpl_posix_spawn
131 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
132 extern int posix_spawn (pid_t *_Restrict_ __pid,
133 const char *_Restrict_ __path,
134 const posix_spawn_file_actions_t *_Restrict_ __file_actions,
135 const posix_spawnattr_t *_Restrict_ __attrp,
136 char *const argv[_Restrict_arr_],
137 char *const envp[_Restrict_arr_]);
141 #if @GNULIB_POSIX_SPAWNP@
142 /* Similar to `posix_spawn' but search for FILE in the PATH.
144 This function is a possible cancellation points and therefore not
145 marked with __THROW. */
146 # if @REPLACE_POSIX_SPAWN@
147 # define posix_spawnp rpl_posix_spawnp
149 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
150 extern int posix_spawnp (pid_t *__pid, const char *__file,
151 const posix_spawn_file_actions_t *__file_actions,
152 const posix_spawnattr_t *__attrp,
153 char *const argv[], char *const envp[]);
158 #if @GNULIB_POSIX_SPAWNATTR_INIT@
159 /* Initialize data structure with attributes for `spawn' to default values. */
160 # if @REPLACE_POSIX_SPAWN@
161 # define posix_spawnattr_init rpl_posix_spawnattr_init
163 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
164 extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW;
168 #if @GNULIB_POSIX_SPAWNATTR_DESTROY@
169 /* Free resources associated with ATTR. */
170 # if @REPLACE_POSIX_SPAWN@
171 # define posix_spawnattr_destroy rpl_posix_spawnattr_destroy
173 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
174 extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW;
178 #if @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@
179 /* Store signal mask for signals with default handling from ATTR in
181 # if @REPLACE_POSIX_SPAWN@
182 # define posix_spawnattr_getsigdefault rpl_posix_spawnattr_getsigdefault
184 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
185 extern int posix_spawnattr_getsigdefault (const posix_spawnattr_t *_Restrict_ __attr,
186 sigset_t *_Restrict_ __sigdefault)
191 #if @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@
192 /* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */
193 # if @REPLACE_POSIX_SPAWN@
194 # define posix_spawnattr_setsigdefault rpl_posix_spawnattr_setsigdefault
196 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
197 extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *_Restrict_ __attr,
198 const sigset_t *_Restrict_ __sigdefault)
203 #if @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@
204 /* Store signal mask for the new process from ATTR in SIGMASK. */
205 # if @REPLACE_POSIX_SPAWN@
206 # define posix_spawnattr_getsigmask rpl_posix_spawnattr_getsigmask
208 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
209 extern int posix_spawnattr_getsigmask (const posix_spawnattr_t *_Restrict_ __attr,
210 sigset_t *_Restrict_ __sigmask) __THROW;
214 #if @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@
215 /* Set signal mask for the new process in ATTR to SIGMASK. */
216 # if @REPLACE_POSIX_SPAWN@
217 # define posix_spawnattr_setsigmask rpl_posix_spawnattr_setsigmask
219 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
220 extern int posix_spawnattr_setsigmask (posix_spawnattr_t *_Restrict_ __attr,
221 const sigset_t *_Restrict_ __sigmask)
226 #if @GNULIB_POSIX_SPAWNATTR_GETFLAGS@
227 /* Get flag word from the attribute structure. */
228 # if @REPLACE_POSIX_SPAWN@
229 # define posix_spawnattr_getflags rpl_posix_spawnattr_getflags
231 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
232 extern int posix_spawnattr_getflags (const posix_spawnattr_t *_Restrict_ __attr,
233 short int *_Restrict_ __flags) __THROW;
237 #if @GNULIB_POSIX_SPAWNATTR_SETFLAGS@
238 /* Store flags in the attribute structure. */
239 # if @REPLACE_POSIX_SPAWN@
240 # define posix_spawnattr_setflags rpl_posix_spawnattr_setflags
242 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
243 extern int posix_spawnattr_setflags (posix_spawnattr_t *__attr,
244 short int __flags) __THROW;
248 #if @GNULIB_POSIX_SPAWNATTR_GETPGROUP@
249 /* Get process group ID from the attribute structure. */
250 # if @REPLACE_POSIX_SPAWN@
251 # define posix_spawnattr_getpgroup rpl_posix_spawnattr_getpgroup
253 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
254 extern int posix_spawnattr_getpgroup (const posix_spawnattr_t *_Restrict_ __attr,
255 pid_t *_Restrict_ __pgroup)
260 #if @GNULIB_POSIX_SPAWNATTR_SETPGROUP@
261 /* Store process group ID in the attribute structure. */
262 # if @REPLACE_POSIX_SPAWN@
263 # define posix_spawnattr_setpgroup rpl_posix_spawnattr_setpgroup
265 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
266 extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr,
267 pid_t __pgroup) __THROW;
271 #if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@
272 /* Get scheduling policy from the attribute structure. */
273 # if @REPLACE_POSIX_SPAWN@
274 # define posix_spawnattr_getschedpolicy rpl_posix_spawnattr_getschedpolicy
276 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
277 extern int posix_spawnattr_getschedpolicy (const posix_spawnattr_t *_Restrict_ __attr,
278 int *_Restrict_ __schedpolicy)
283 #if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@
284 /* Store scheduling policy in the attribute structure. */
285 # if @REPLACE_POSIX_SPAWN@
286 # define posix_spawnattr_setschedpolicy rpl_posix_spawnattr_setschedpolicy
288 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
289 extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
290 int __schedpolicy) __THROW;
294 #if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@
295 /* Get scheduling parameters from the attribute structure. */
296 # if @REPLACE_POSIX_SPAWN@
297 # define posix_spawnattr_getschedparam rpl_posix_spawnattr_getschedparam
299 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
300 extern int posix_spawnattr_getschedparam (const posix_spawnattr_t *_Restrict_ __attr,
301 struct sched_param *_Restrict_ __schedparam) __THROW;
305 #if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@
306 /* Store scheduling parameters in the attribute structure. */
307 # if @REPLACE_POSIX_SPAWN@
308 # define posix_spawnattr_setschedparam rpl_posix_spawnattr_setschedparam
310 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
311 extern int posix_spawnattr_setschedparam (posix_spawnattr_t *_Restrict_ __attr,
312 const struct sched_param *_Restrict_ __schedparam) __THROW;
317 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@
318 /* Initialize data structure for file attribute for `spawn' call. */
319 # if @REPLACE_POSIX_SPAWN@
320 # define posix_spawn_file_actions_init rpl_posix_spawn_file_actions_init
322 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
323 extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *__file_actions) __THROW;
327 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@
328 /* Free resources associated with FILE-ACTIONS. */
329 # if @REPLACE_POSIX_SPAWN@
330 # define posix_spawn_file_actions_destroy rpl_posix_spawn_file_actions_destroy
332 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
333 extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *__file_actions) __THROW;
337 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@
338 /* Add an action to FILE-ACTIONS which tells the implementation to call
339 `open' for the given file during the `spawn' call. */
340 # if @REPLACE_POSIX_SPAWN@
341 # define posix_spawn_file_actions_addopen rpl_posix_spawn_file_actions_addopen
343 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
344 extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *_Restrict_ __file_actions,
346 const char *_Restrict_ __path,
347 int __oflag, mode_t __mode)
352 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@
353 /* Add an action to FILE-ACTIONS which tells the implementation to call
354 `close' for the given file descriptor during the `spawn' call. */
355 # if @REPLACE_POSIX_SPAWN@
356 # define posix_spawn_file_actions_addclose rpl_posix_spawn_file_actions_addclose
358 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
359 extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *__file_actions,
365 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@
366 /* Add an action to FILE-ACTIONS which tells the implementation to call
367 `dup2' for the given file descriptors during the `spawn' call. */
368 # if @REPLACE_POSIX_SPAWN@
369 # define posix_spawn_file_actions_adddup2 rpl_posix_spawn_file_actions_adddup2
371 # if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
372 extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *__file_actions,
373 int __fd, int __newfd) __THROW;
383 #endif /* _GL_SPAWN_H */
384 #endif /* _GL_SPAWN_H */