1 | /* Definitions for POSIX spawn interface.
|
---|
2 | Copyright (C) 2000 Free Software Foundation, Inc.
|
---|
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
|
---|
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.
|
---|
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
|
---|
13 | Lesser General Public License for more details.
|
---|
14 |
|
---|
15 | You should have received a copy of the GNU Lesser General Public
|
---|
16 | License along with the GNU C Library; if not, write to the Free
|
---|
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
---|
18 | 02111-1307 USA. */
|
---|
19 |
|
---|
20 | #ifndef _SPAWN_H
|
---|
21 | #define _SPAWN_H 1
|
---|
22 |
|
---|
23 | #include <features.h>
|
---|
24 | #include <sched.h>
|
---|
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
|
---|
60 |
|
---|
61 |
|
---|
62 | __BEGIN_DECLS
|
---|
63 |
|
---|
64 | /* Spawn a new process executing PATH with the attributes describes in *ATTRP.
|
---|
65 | Before running the process perform the actions described in FILE-ACTIONS. */
|
---|
66 | extern int posix_spawn (pid_t *__restrict __pid,
|
---|
67 | __const char *__restrict __path,
|
---|
68 | __const posix_spawn_file_actions_t *__restrict
|
---|
69 | __file_actions,
|
---|
70 | __const posix_spawnattr_t *__restrict __attrp,
|
---|
71 | char *__const argv[__restrict_arr],
|
---|
72 | char *__const envp[__restrict_arr]) __THROW;
|
---|
73 |
|
---|
74 | /* Similar to `posix_spawn' but search for FILE in the PATH. */
|
---|
75 | extern int posix_spawnp (pid_t *__pid, __const char *__file,
|
---|
76 | __const posix_spawn_file_actions_t *__file_actions,
|
---|
77 | __const posix_spawnattr_t *__attrp,
|
---|
78 | char *__const argv[], char *__const envp[]) __THROW;
|
---|
79 |
|
---|
80 |
|
---|
81 | /* Initialize data structure with attributes for `spawn' to default values. */
|
---|
82 | extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW;
|
---|
83 |
|
---|
84 | /* Free resources associated with ATTR. */
|
---|
85 | extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW;
|
---|
86 |
|
---|
87 | /* Store signal mask for signals with default handling from ATTR in
|
---|
88 | SIGDEFAULT. */
|
---|
89 | extern int posix_spawnattr_getsigdefault (__const posix_spawnattr_t *
|
---|
90 | __restrict __attr,
|
---|
91 | sigset_t *__restrict __sigdefault)
|
---|
92 | __THROW;
|
---|
93 |
|
---|
94 | /* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */
|
---|
95 | extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *__restrict __attr,
|
---|
96 | __const sigset_t *__restrict
|
---|
97 | __sigdefault)
|
---|
98 | __THROW;
|
---|
99 |
|
---|
100 | /* Store signal mask for the new process from ATTR in SIGMASK. */
|
---|
101 | extern int posix_spawnattr_getsigmask (__const posix_spawnattr_t *__restrict
|
---|
102 | __attr,
|
---|
103 | sigset_t *__restrict __sigmask) __THROW;
|
---|
104 |
|
---|
105 | /* Set signal mask for the new process in ATTR to SIGMASK. */
|
---|
106 | extern int posix_spawnattr_setsigmask (posix_spawnattr_t *__restrict __attr,
|
---|
107 | __const sigset_t *__restrict __sigmask)
|
---|
108 | __THROW;
|
---|
109 |
|
---|
110 | /* Get flag word from the attribute structure. */
|
---|
111 | extern int posix_spawnattr_getflags (__const posix_spawnattr_t *__restrict
|
---|
112 | __attr,
|
---|
113 | short int *__restrict __flags) __THROW;
|
---|
114 |
|
---|
115 | /* Store flags in the attribute structure. */
|
---|
116 | extern int posix_spawnattr_setflags (posix_spawnattr_t *_attr,
|
---|
117 | short int __flags) __THROW;
|
---|
118 |
|
---|
119 | /* Get process group ID from the attribute structure. */
|
---|
120 | extern int posix_spawnattr_getpgroup (__const posix_spawnattr_t *__restrict
|
---|
121 | __attr, pid_t *__restrict __pgroup)
|
---|
122 | __THROW;
|
---|
123 |
|
---|
124 | /* Store process group ID in the attribute structure. */
|
---|
125 | extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr,
|
---|
126 | pid_t __pgroup) __THROW;
|
---|
127 |
|
---|
128 | /* Get scheduling policy from the attribute structure. */
|
---|
129 | extern int posix_spawnattr_getschedpolicy (__const posix_spawnattr_t *
|
---|
130 | __restrict __attr,
|
---|
131 | int *__restrict __schedpolicy)
|
---|
132 | __THROW;
|
---|
133 |
|
---|
134 | /* Store scheduling policy in the attribute structure. */
|
---|
135 | extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
|
---|
136 | int __schedpolicy) __THROW;
|
---|
137 |
|
---|
138 | /* Get scheduling parameters from the attribute structure. */
|
---|
139 | extern int posix_spawnattr_getschedparam (__const posix_spawnattr_t *
|
---|
140 | __restrict __attr,
|
---|
141 | struct sched_param *__restrict
|
---|
142 | __schedparam) __THROW;
|
---|
143 |
|
---|
144 | /* Store scheduling parameters in the attribute structure. */
|
---|
145 | extern int posix_spawnattr_setschedparam (posix_spawnattr_t *__restrict __attr,
|
---|
146 | const struct sched_param *
|
---|
147 | __restrict __schedparam) __THROW;
|
---|
148 |
|
---|
149 |
|
---|
150 | /* Initialize data structure for file attribute for `spawn' call. */
|
---|
151 | extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *
|
---|
152 | __file_actions) __THROW;
|
---|
153 |
|
---|
154 | /* Free resources associated with FILE-ACTIONS. */
|
---|
155 | extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *
|
---|
156 | __file_actions) __THROW;
|
---|
157 |
|
---|
158 | /* Add an action to FILE-ACTIONS which tells the implementation to call
|
---|
159 | `open' for the given file during the `spawn' call. */
|
---|
160 | extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *
|
---|
161 | __restrict __file_actions,
|
---|
162 | int __fd,
|
---|
163 | __const char *__restrict __path,
|
---|
164 | int __oflag, mode_t __mode)
|
---|
165 | __THROW;
|
---|
166 |
|
---|
167 | /* Add an action to FILE-ACTIONS which tells the implementation to call
|
---|
168 | `close' for the given file descriptor during the `spawn' call. */
|
---|
169 | extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *
|
---|
170 | __file_actions, int __fd)
|
---|
171 | __THROW;
|
---|
172 |
|
---|
173 | /* Add an action to FILE-ACTIONS which tells the implementation to call
|
---|
174 | `dup2' for the given file descriptors during the `spawn' call. */
|
---|
175 | extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *
|
---|
176 | __file_actions,
|
---|
177 | int __fd, int __newfd) __THROW;
|
---|
178 |
|
---|
179 | __END_DECLS
|
---|
180 |
|
---|
181 | #endif /* spawn.h */
|
---|