xref: /titanic_51/usr/src/head/spawn.h (revision 50981ffc7e4c5048d14890df805afee6ec113991)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SPAWN_H
28 #define	_SPAWN_H
29 
30 #include <sys/feature_tests.h>
31 #include <sys/types.h>
32 #include <signal.h>
33 #include <sched.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * flags for posix_spawnattr_setflags()
41  */
42 #define	POSIX_SPAWN_RESETIDS		0x0001
43 #define	POSIX_SPAWN_SETPGROUP		0x0002
44 #define	POSIX_SPAWN_SETSIGDEF		0x0004
45 #define	POSIX_SPAWN_SETSIGMASK		0x0008
46 #define	POSIX_SPAWN_SETSCHEDPARAM	0x0010
47 #define	POSIX_SPAWN_SETSCHEDULER	0x0020
48 /*
49  * non-portable Solaris extensions
50  */
51 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
52 #define	POSIX_SPAWN_SETSIGIGN_NP	0x0800
53 #define	POSIX_SPAWN_NOSIGCHLD_NP	0x1000
54 #define	POSIX_SPAWN_WAITPID_NP		0x2000
55 #define	POSIX_SPAWN_NOEXECERR_NP	0x4000
56 #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
57 
58 typedef struct {
59 	void *__spawn_attrp;	/* implementation-private */
60 } posix_spawnattr_t;
61 
62 typedef struct {
63 	void *__file_attrp;	/* implementation-private */
64 } posix_spawn_file_actions_t;
65 
66 #if defined(__STDC__)
67 
68 extern int posix_spawn(
69 	pid_t *_RESTRICT_KYWD pid,
70 	const char *_RESTRICT_KYWD path,
71 	const posix_spawn_file_actions_t *file_actions,
72 	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
73 	char *const argv[_RESTRICT_KYWD],
74 	char *const envp[_RESTRICT_KYWD]);
75 
76 extern int posix_spawnp(
77 	pid_t *_RESTRICT_KYWD pid,
78 	const char *_RESTRICT_KYWD file,
79 	const posix_spawn_file_actions_t *file_actions,
80 	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
81 	char *const argv[_RESTRICT_KYWD],
82 	char *const envp[_RESTRICT_KYWD]);
83 
84 extern int posix_spawn_file_actions_init(
85 	posix_spawn_file_actions_t *file_actions);
86 
87 extern int posix_spawn_file_actions_destroy(
88 	posix_spawn_file_actions_t *file_actions);
89 
90 extern int posix_spawn_file_actions_addopen(
91 	posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
92 	int filedes,
93 	const char *_RESTRICT_KYWD path,
94 	int oflag,
95 	mode_t mode);
96 
97 extern int posix_spawn_file_actions_addclose(
98 	posix_spawn_file_actions_t *file_actions,
99 	int filedes);
100 
101 extern int posix_spawn_file_actions_adddup2(
102 	posix_spawn_file_actions_t *file_actions,
103 	int filedes,
104 	int newfiledes);
105 
106 extern int posix_spawnattr_init(
107 	posix_spawnattr_t *attr);
108 
109 extern int posix_spawnattr_destroy(
110 	posix_spawnattr_t *attr);
111 
112 extern int posix_spawnattr_setflags(
113 	posix_spawnattr_t *attr,
114 	short flags);
115 
116 extern int posix_spawnattr_getflags(
117 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
118 	short *_RESTRICT_KYWD flags);
119 
120 extern int posix_spawnattr_setpgroup(
121 	posix_spawnattr_t *attr,
122 	pid_t pgroup);
123 
124 extern int posix_spawnattr_getpgroup(
125 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
126 	pid_t *_RESTRICT_KYWD pgroup);
127 
128 extern int posix_spawnattr_setschedparam(
129 	posix_spawnattr_t *_RESTRICT_KYWD attr,
130 	const struct sched_param *_RESTRICT_KYWD schedparam);
131 
132 extern int posix_spawnattr_getschedparam(
133 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
134 	struct sched_param *_RESTRICT_KYWD schedparam);
135 
136 extern int posix_spawnattr_setschedpolicy(
137 	posix_spawnattr_t *attr,
138 	int schedpolicy);
139 
140 extern int posix_spawnattr_getschedpolicy(
141 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
142 	int *_RESTRICT_KYWD schedpolicy);
143 
144 extern int posix_spawnattr_setsigdefault(
145 	posix_spawnattr_t *_RESTRICT_KYWD attr,
146 	const sigset_t *_RESTRICT_KYWD sigdefault);
147 
148 extern int posix_spawnattr_getsigdefault(
149 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
150 	sigset_t *_RESTRICT_KYWD sigdefault);
151 
152 /*
153  * non-portable Solaris extensions
154  */
155 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
156 
157 extern int posix_spawnattr_setsigignore_np(
158 	posix_spawnattr_t *_RESTRICT_KYWD attr,
159 	const sigset_t *_RESTRICT_KYWD sigignore);
160 
161 extern int posix_spawnattr_getsigignore_np(
162 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
163 	sigset_t *_RESTRICT_KYWD sigignore);
164 
165 #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
166 
167 extern int posix_spawnattr_setsigmask(
168 	posix_spawnattr_t *_RESTRICT_KYWD attr,
169 	const sigset_t *_RESTRICT_KYWD sigmask);
170 
171 extern int posix_spawnattr_getsigmask(
172 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
173 	sigset_t *_RESTRICT_KYWD sigmask);
174 
175 #else	/* __STDC__ */
176 
177 extern int posix_spawn();
178 extern int posix_spawnp();
179 extern int posix_spawn_file_actions_init();
180 extern int posix_spawn_file_actions_destroy();
181 extern int posix_spawn_file_actions_addopen();
182 extern int posix_spawn_file_actions_addclose();
183 extern int posix_spawn_file_actions_adddup2();
184 extern int posix_spawnattr_init();
185 extern int posix_spawnattr_destroy();
186 extern int posix_spawnattr_setflags();
187 extern int posix_spawnattr_getflags();
188 extern int posix_spawnattr_setpgroup();
189 extern int posix_spawnattr_getpgroup();
190 extern int posix_spawnattr_setschedparam();
191 extern int posix_spawnattr_getschedparam();
192 extern int posix_spawnattr_setschedpolicy();
193 extern int posix_spawnattr_getschedpolicy();
194 extern int posix_spawnattr_setsigdefault();
195 extern int posix_spawnattr_getsigdefault();
196 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
197 extern int posix_spawnattr_setsigignore_np();
198 extern int posix_spawnattr_getsigignore_np();
199 #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
200 extern int posix_spawnattr_setsigmask();
201 extern int posix_spawnattr_getsigmask();
202 
203 #endif	/* __STDC__ */
204 
205 #ifdef	__cplusplus
206 }
207 #endif
208 
209 #endif	/* _SPAWN_H */
210