]>
Commit | Line | Data |
---|---|---|
a5a6f926 | 1 | /* Definitions for POSIX spawn interface. |
d4697bc9 | 2 | Copyright (C) 2000-2014 Free Software Foundation, Inc. |
a5a6f926 UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
a5a6f926 UD |
9 | |
10 | The GNU C Library 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 GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
a5a6f926 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
a5a6f926 UD |
18 | |
19 | #ifndef _SPAWN_H | |
20 | #define _SPAWN_H 1 | |
21 | ||
22 | #include <features.h> | |
23 | #include <sched.h> | |
d94a4670 | 24 | #define __need_sigset_t |
a5a6f926 UD |
25 | #include <signal.h> |
26 | #include <sys/types.h> | |
27 | ||
28 | ||
29 | /* Data structure to contain attributes for thread creation. */ | |
30 | typedef struct | |
31 | { | |
32 | short int __flags; | |
33 | pid_t __pgrp; | |
34 | sigset_t __sd; | |
35 | sigset_t __ss; | |
36 | struct sched_param __sp; | |
37 | int __policy; | |
38 | int __pad[16]; | |
39 | } posix_spawnattr_t; | |
40 | ||
41 | ||
42 | /* Data structure to contain information about the actions to be | |
43 | performed in the new process with respect to file descriptors. */ | |
44 | typedef struct | |
45 | { | |
46 | int __allocated; | |
47 | int __used; | |
48 | struct __spawn_action *__actions; | |
49 | int __pad[16]; | |
50 | } posix_spawn_file_actions_t; | |
51 | ||
52 | ||
53 | /* Flags to be set in the `posix_spawnattr_t'. */ | |
54 | #define POSIX_SPAWN_RESETIDS 0x01 | |
55 | #define POSIX_SPAWN_SETPGROUP 0x02 | |
56 | #define POSIX_SPAWN_SETSIGDEF 0x04 | |
57 | #define POSIX_SPAWN_SETSIGMASK 0x08 | |
58 | #define POSIX_SPAWN_SETSCHEDPARAM 0x10 | |
59 | #define POSIX_SPAWN_SETSCHEDULER 0x20 | |
9ad68422 UD |
60 | #ifdef __USE_GNU |
61 | # define POSIX_SPAWN_USEVFORK 0x40 | |
62 | #endif | |
a5a6f926 UD |
63 | |
64 | ||
65 | __BEGIN_DECLS | |
66 | ||
67 | /* Spawn a new process executing PATH with the attributes describes in *ATTRP. | |
2c008571 UD |
68 | Before running the process perform the actions described in FILE-ACTIONS. |
69 | ||
4c1423ed | 70 | This function is a possible cancellation point and therefore not |
2c008571 | 71 | marked with __THROW. */ |
98cbe360 | 72 | extern int posix_spawn (pid_t *__restrict __pid, |
a784e502 UD |
73 | const char *__restrict __path, |
74 | const posix_spawn_file_actions_t *__restrict | |
98cbe360 | 75 | __file_actions, |
a784e502 UD |
76 | const posix_spawnattr_t *__restrict __attrp, |
77 | char *const __argv[__restrict_arr], | |
78 | char *const __envp[__restrict_arr]); | |
2c008571 UD |
79 | |
80 | /* Similar to `posix_spawn' but search for FILE in the PATH. | |
a5a6f926 | 81 | |
4c1423ed | 82 | This function is a possible cancellation point and therefore not |
2c008571 | 83 | marked with __THROW. */ |
a784e502 UD |
84 | extern int posix_spawnp (pid_t *__pid, const char *__file, |
85 | const posix_spawn_file_actions_t *__file_actions, | |
86 | const posix_spawnattr_t *__attrp, | |
87 | char *const __argv[], char *const __envp[]); | |
a5a6f926 UD |
88 | |
89 | ||
90 | /* Initialize data structure with attributes for `spawn' to default values. */ | |
91 | extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW; | |
92 | ||
93 | /* Free resources associated with ATTR. */ | |
94 | extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW; | |
95 | ||
96 | /* Store signal mask for signals with default handling from ATTR in | |
97 | SIGDEFAULT. */ | |
a784e502 | 98 | extern int posix_spawnattr_getsigdefault (const posix_spawnattr_t * |
98cbe360 UD |
99 | __restrict __attr, |
100 | sigset_t *__restrict __sigdefault) | |
101 | __THROW; | |
a5a6f926 UD |
102 | |
103 | /* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */ | |
98cbe360 | 104 | extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *__restrict __attr, |
a784e502 | 105 | const sigset_t *__restrict |
98cbe360 | 106 | __sigdefault) |
261df086 | 107 | __THROW; |
a5a6f926 UD |
108 | |
109 | /* Store signal mask for the new process from ATTR in SIGMASK. */ | |
a784e502 | 110 | extern int posix_spawnattr_getsigmask (const posix_spawnattr_t *__restrict |
98cbe360 UD |
111 | __attr, |
112 | sigset_t *__restrict __sigmask) __THROW; | |
a5a6f926 UD |
113 | |
114 | /* Set signal mask for the new process in ATTR to SIGMASK. */ | |
98cbe360 | 115 | extern int posix_spawnattr_setsigmask (posix_spawnattr_t *__restrict __attr, |
a784e502 | 116 | const sigset_t *__restrict __sigmask) |
98cbe360 | 117 | __THROW; |
a5a6f926 UD |
118 | |
119 | /* Get flag word from the attribute structure. */ | |
a784e502 | 120 | extern int posix_spawnattr_getflags (const posix_spawnattr_t *__restrict |
98cbe360 UD |
121 | __attr, |
122 | short int *__restrict __flags) __THROW; | |
a5a6f926 UD |
123 | |
124 | /* Store flags in the attribute structure. */ | |
125 | extern int posix_spawnattr_setflags (posix_spawnattr_t *_attr, | |
126 | short int __flags) __THROW; | |
127 | ||
128 | /* Get process group ID from the attribute structure. */ | |
a784e502 | 129 | extern int posix_spawnattr_getpgroup (const posix_spawnattr_t *__restrict |
98cbe360 UD |
130 | __attr, pid_t *__restrict __pgroup) |
131 | __THROW; | |
a5a6f926 UD |
132 | |
133 | /* Store process group ID in the attribute structure. */ | |
134 | extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr, | |
135 | pid_t __pgroup) __THROW; | |
136 | ||
137 | /* Get scheduling policy from the attribute structure. */ | |
a784e502 | 138 | extern int posix_spawnattr_getschedpolicy (const posix_spawnattr_t * |
98cbe360 UD |
139 | __restrict __attr, |
140 | int *__restrict __schedpolicy) | |
141 | __THROW; | |
a5a6f926 UD |
142 | |
143 | /* Store scheduling policy in the attribute structure. */ | |
144 | extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr, | |
145 | int __schedpolicy) __THROW; | |
146 | ||
98cbe360 | 147 | /* Get scheduling parameters from the attribute structure. */ |
a784e502 | 148 | extern int posix_spawnattr_getschedparam (const posix_spawnattr_t * |
98cbe360 UD |
149 | __restrict __attr, |
150 | struct sched_param *__restrict | |
151 | __schedparam) __THROW; | |
152 | ||
153 | /* Store scheduling parameters in the attribute structure. */ | |
154 | extern int posix_spawnattr_setschedparam (posix_spawnattr_t *__restrict __attr, | |
155 | const struct sched_param * | |
156 | __restrict __schedparam) __THROW; | |
157 | ||
a5a6f926 UD |
158 | |
159 | /* Initialize data structure for file attribute for `spawn' call. */ | |
160 | extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t * | |
161 | __file_actions) __THROW; | |
162 | ||
163 | /* Free resources associated with FILE-ACTIONS. */ | |
164 | extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t * | |
165 | __file_actions) __THROW; | |
166 | ||
167 | /* Add an action to FILE-ACTIONS which tells the implementation to call | |
168 | `open' for the given file during the `spawn' call. */ | |
169 | extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t * | |
98cbe360 UD |
170 | __restrict __file_actions, |
171 | int __fd, | |
a784e502 | 172 | const char *__restrict __path, |
a5a6f926 UD |
173 | int __oflag, mode_t __mode) |
174 | __THROW; | |
175 | ||
176 | /* Add an action to FILE-ACTIONS which tells the implementation to call | |
177 | `close' for the given file descriptor during the `spawn' call. */ | |
178 | extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t * | |
179 | __file_actions, int __fd) | |
180 | __THROW; | |
181 | ||
182 | /* Add an action to FILE-ACTIONS which tells the implementation to call | |
183 | `dup2' for the given file descriptors during the `spawn' call. */ | |
184 | extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t * | |
185 | __file_actions, | |
186 | int __fd, int __newfd) __THROW; | |
187 | ||
188 | __END_DECLS | |
189 | ||
190 | #endif /* spawn.h */ |