xref: /titanic_52/usr/src/head/spawn.h (revision 107875b08504ad7f74a2abc64d3862ee8845d5ef)
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 2006 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/feature_tests.h>
33 #include <sys/types.h>
34 #include <signal.h>
35 #include <sched.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * flags for posix_spawnattr_setflags()
43  */
44 #define	POSIX_SPAWN_RESETIDS		0x0001
45 #define	POSIX_SPAWN_SETPGROUP		0x0002
46 #define	POSIX_SPAWN_SETSIGDEF		0x0004
47 #define	POSIX_SPAWN_SETSIGMASK		0x0008
48 #define	POSIX_SPAWN_SETSCHEDPARAM	0x0010
49 #define	POSIX_SPAWN_SETSCHEDULER	0x0020
50 /*
51  * non-portable Solaris extensions
52  */
53 #define	POSIX_SPAWN_NOSIGCHLD_NP	0x1000
54 #define	POSIX_SPAWN_WAITPID_NP		0x2000
55 
56 typedef struct {
57 	void *__spawn_attrp;	/* implementation-private */
58 } posix_spawnattr_t;
59 
60 typedef struct {
61 	void *__file_attrp;	/* implementation-private */
62 } posix_spawn_file_actions_t;
63 
64 #if defined(__STDC__)
65 
66 extern int posix_spawn(
67 	pid_t *_RESTRICT_KYWD pid,
68 	const char *_RESTRICT_KYWD path,
69 	const posix_spawn_file_actions_t *file_actions,
70 	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
71 	char *const argv[_RESTRICT_KYWD],
72 	char *const envp[_RESTRICT_KYWD]);
73 
74 extern int posix_spawnp(
75 	pid_t *_RESTRICT_KYWD pid,
76 	const char *_RESTRICT_KYWD file,
77 	const posix_spawn_file_actions_t *file_actions,
78 	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
79 	char *const argv[_RESTRICT_KYWD],
80 	char *const envp[_RESTRICT_KYWD]);
81 
82 extern int posix_spawn_file_actions_init(
83 	posix_spawn_file_actions_t *file_actions);
84 
85 extern int posix_spawn_file_actions_destroy(
86 	posix_spawn_file_actions_t *file_actions);
87 
88 extern int posix_spawn_file_actions_addopen(
89 	posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
90 	int filedes,
91 	const char *_RESTRICT_KYWD path,
92 	int oflag,
93 	mode_t mode);
94 
95 extern int posix_spawn_file_actions_addclose(
96 	posix_spawn_file_actions_t *file_actions,
97 	int filedes);
98 
99 extern int posix_spawn_file_actions_adddup2(
100 	posix_spawn_file_actions_t *file_actions,
101 	int filedes,
102 	int newfiledes);
103 
104 extern int posix_spawnattr_init(
105 	posix_spawnattr_t *attr);
106 
107 extern int posix_spawnattr_destroy(
108 	posix_spawnattr_t *attr);
109 
110 extern int posix_spawnattr_setflags(
111 	posix_spawnattr_t *attr,
112 	short flags);
113 
114 extern int posix_spawnattr_getflags(
115 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
116 	short *_RESTRICT_KYWD flags);
117 
118 extern int posix_spawnattr_setpgroup(
119 	posix_spawnattr_t *attr,
120 	pid_t pgroup);
121 
122 extern int posix_spawnattr_getpgroup(
123 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
124 	pid_t *_RESTRICT_KYWD pgroup);
125 
126 extern int posix_spawnattr_setschedparam(
127 	posix_spawnattr_t *_RESTRICT_KYWD attr,
128 	const struct sched_param *_RESTRICT_KYWD schedparam);
129 
130 extern int posix_spawnattr_getschedparam(
131 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
132 	struct sched_param *_RESTRICT_KYWD schedparam);
133 
134 extern int posix_spawnattr_setschedpolicy(
135 	posix_spawnattr_t *attr,
136 	int schedpolicy);
137 
138 extern int posix_spawnattr_getschedpolicy(
139 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
140 	int *_RESTRICT_KYWD schedpolicy);
141 
142 extern int posix_spawnattr_setsigdefault(
143 	posix_spawnattr_t *_RESTRICT_KYWD attr,
144 	const sigset_t *_RESTRICT_KYWD sigdefault);
145 
146 extern int posix_spawnattr_getsigdefault(
147 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
148 	sigset_t *_RESTRICT_KYWD sigdefault);
149 
150 extern int posix_spawnattr_setsigmask(
151 	posix_spawnattr_t *_RESTRICT_KYWD attr,
152 	const sigset_t *_RESTRICT_KYWD sigmask);
153 
154 extern int posix_spawnattr_getsigmask(
155 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
156 	sigset_t *_RESTRICT_KYWD sigmask);
157 
158 #else	/* __STDC__ */
159 
160 extern int posix_spawn();
161 extern int posix_spawnp();
162 extern int posix_spawn_file_actions_init();
163 extern int posix_spawn_file_actions_destroy();
164 extern int posix_spawn_file_actions_addopen();
165 extern int posix_spawn_file_actions_addclose();
166 extern int posix_spawn_file_actions_adddup2();
167 extern int posix_spawnattr_init();
168 extern int posix_spawnattr_destroy();
169 extern int posix_spawnattr_setflags();
170 extern int posix_spawnattr_getflags();
171 extern int posix_spawnattr_setpgroup();
172 extern int posix_spawnattr_getpgroup();
173 extern int posix_spawnattr_setschedparam();
174 extern int posix_spawnattr_getschedparam();
175 extern int posix_spawnattr_setschedpolicy();
176 extern int posix_spawnattr_getschedpolicy();
177 extern int posix_spawnattr_setsigdefault();
178 extern int posix_spawnattr_getsigdefault();
179 extern int posix_spawnattr_setsigmask();
180 extern int posix_spawnattr_getsigmask();
181 
182 #endif	/* __STDC__ */
183 
184 #ifdef	__cplusplus
185 }
186 #endif
187 
188 #endif	/* _SPAWN_H */
189