xref: /titanic_41/usr/src/head/spawn.h (revision cc1a9a89a73172cc2db053635fab3b1b91691657)
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 #define	POSIX_SPAWN_NOSIGCHLD_NP	0x1000
52 #define	POSIX_SPAWN_WAITPID_NP		0x2000
53 #define	POSIX_SPAWN_NOEXECERR_NP	0x4000
54 
55 typedef struct {
56 	void *__spawn_attrp;	/* implementation-private */
57 } posix_spawnattr_t;
58 
59 typedef struct {
60 	void *__file_attrp;	/* implementation-private */
61 } posix_spawn_file_actions_t;
62 
63 #if defined(__STDC__)
64 
65 extern int posix_spawn(
66 	pid_t *_RESTRICT_KYWD pid,
67 	const char *_RESTRICT_KYWD path,
68 	const posix_spawn_file_actions_t *file_actions,
69 	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
70 	char *const argv[_RESTRICT_KYWD],
71 	char *const envp[_RESTRICT_KYWD]);
72 
73 extern int posix_spawnp(
74 	pid_t *_RESTRICT_KYWD pid,
75 	const char *_RESTRICT_KYWD file,
76 	const posix_spawn_file_actions_t *file_actions,
77 	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
78 	char *const argv[_RESTRICT_KYWD],
79 	char *const envp[_RESTRICT_KYWD]);
80 
81 extern int posix_spawn_file_actions_init(
82 	posix_spawn_file_actions_t *file_actions);
83 
84 extern int posix_spawn_file_actions_destroy(
85 	posix_spawn_file_actions_t *file_actions);
86 
87 extern int posix_spawn_file_actions_addopen(
88 	posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
89 	int filedes,
90 	const char *_RESTRICT_KYWD path,
91 	int oflag,
92 	mode_t mode);
93 
94 extern int posix_spawn_file_actions_addclose(
95 	posix_spawn_file_actions_t *file_actions,
96 	int filedes);
97 
98 extern int posix_spawn_file_actions_adddup2(
99 	posix_spawn_file_actions_t *file_actions,
100 	int filedes,
101 	int newfiledes);
102 
103 extern int posix_spawnattr_init(
104 	posix_spawnattr_t *attr);
105 
106 extern int posix_spawnattr_destroy(
107 	posix_spawnattr_t *attr);
108 
109 extern int posix_spawnattr_setflags(
110 	posix_spawnattr_t *attr,
111 	short flags);
112 
113 extern int posix_spawnattr_getflags(
114 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
115 	short *_RESTRICT_KYWD flags);
116 
117 extern int posix_spawnattr_setpgroup(
118 	posix_spawnattr_t *attr,
119 	pid_t pgroup);
120 
121 extern int posix_spawnattr_getpgroup(
122 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
123 	pid_t *_RESTRICT_KYWD pgroup);
124 
125 extern int posix_spawnattr_setschedparam(
126 	posix_spawnattr_t *_RESTRICT_KYWD attr,
127 	const struct sched_param *_RESTRICT_KYWD schedparam);
128 
129 extern int posix_spawnattr_getschedparam(
130 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
131 	struct sched_param *_RESTRICT_KYWD schedparam);
132 
133 extern int posix_spawnattr_setschedpolicy(
134 	posix_spawnattr_t *attr,
135 	int schedpolicy);
136 
137 extern int posix_spawnattr_getschedpolicy(
138 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
139 	int *_RESTRICT_KYWD schedpolicy);
140 
141 extern int posix_spawnattr_setsigdefault(
142 	posix_spawnattr_t *_RESTRICT_KYWD attr,
143 	const sigset_t *_RESTRICT_KYWD sigdefault);
144 
145 extern int posix_spawnattr_getsigdefault(
146 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
147 	sigset_t *_RESTRICT_KYWD sigdefault);
148 
149 extern int posix_spawnattr_setsigmask(
150 	posix_spawnattr_t *_RESTRICT_KYWD attr,
151 	const sigset_t *_RESTRICT_KYWD sigmask);
152 
153 extern int posix_spawnattr_getsigmask(
154 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
155 	sigset_t *_RESTRICT_KYWD sigmask);
156 
157 #else	/* __STDC__ */
158 
159 extern int posix_spawn();
160 extern int posix_spawnp();
161 extern int posix_spawn_file_actions_init();
162 extern int posix_spawn_file_actions_destroy();
163 extern int posix_spawn_file_actions_addopen();
164 extern int posix_spawn_file_actions_addclose();
165 extern int posix_spawn_file_actions_adddup2();
166 extern int posix_spawnattr_init();
167 extern int posix_spawnattr_destroy();
168 extern int posix_spawnattr_setflags();
169 extern int posix_spawnattr_getflags();
170 extern int posix_spawnattr_setpgroup();
171 extern int posix_spawnattr_getpgroup();
172 extern int posix_spawnattr_setschedparam();
173 extern int posix_spawnattr_getschedparam();
174 extern int posix_spawnattr_setschedpolicy();
175 extern int posix_spawnattr_getschedpolicy();
176 extern int posix_spawnattr_setsigdefault();
177 extern int posix_spawnattr_getsigdefault();
178 extern int posix_spawnattr_setsigmask();
179 extern int posix_spawnattr_getsigmask();
180 
181 #endif	/* __STDC__ */
182 
183 #ifdef	__cplusplus
184 }
185 #endif
186 
187 #endif	/* _SPAWN_H */
188