xref: /titanic_53/usr/src/head/spawn.h (revision 462453d2d0c563559a4caf186db76954e563bd1a)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5657b1f3dSraf  * Common Development and Distribution License (the "License").
6657b1f3dSraf  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21657b1f3dSraf 
227c478bd9Sstevel@tonic-gate /*
2308556f6cSRoger A. Faulkner  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
27*462453d2SMatthew Ahrens /*
28*462453d2SMatthew Ahrens  * Copyright (c) 2011 by Delphix. All rights reserved.
29*462453d2SMatthew Ahrens  */
30*462453d2SMatthew Ahrens 
317c478bd9Sstevel@tonic-gate #ifndef _SPAWN_H
327c478bd9Sstevel@tonic-gate #define	_SPAWN_H
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
357c478bd9Sstevel@tonic-gate #include <sys/types.h>
367c478bd9Sstevel@tonic-gate #include <signal.h>
377c478bd9Sstevel@tonic-gate #include <sched.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
407c478bd9Sstevel@tonic-gate extern "C" {
417c478bd9Sstevel@tonic-gate #endif
427c478bd9Sstevel@tonic-gate 
43657b1f3dSraf /*
44657b1f3dSraf  * flags for posix_spawnattr_setflags()
45657b1f3dSraf  */
46657b1f3dSraf #define	POSIX_SPAWN_RESETIDS		0x0001
47657b1f3dSraf #define	POSIX_SPAWN_SETPGROUP		0x0002
48657b1f3dSraf #define	POSIX_SPAWN_SETSIGDEF		0x0004
49657b1f3dSraf #define	POSIX_SPAWN_SETSIGMASK		0x0008
50657b1f3dSraf #define	POSIX_SPAWN_SETSCHEDPARAM	0x0010
51657b1f3dSraf #define	POSIX_SPAWN_SETSCHEDULER	0x0020
52657b1f3dSraf /*
53657b1f3dSraf  * non-portable Solaris extensions
54657b1f3dSraf  */
5503bc411dSRoger A. Faulkner #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
5603bc411dSRoger A. Faulkner #define	POSIX_SPAWN_SETSIGIGN_NP	0x0800
57657b1f3dSraf #define	POSIX_SPAWN_NOSIGCHLD_NP	0x1000
58657b1f3dSraf #define	POSIX_SPAWN_WAITPID_NP		0x2000
59f9f6ed06SRoger A. Faulkner #define	POSIX_SPAWN_NOEXECERR_NP	0x4000
6003bc411dSRoger A. Faulkner #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate typedef struct {
637c478bd9Sstevel@tonic-gate 	void *__spawn_attrp;	/* implementation-private */
647c478bd9Sstevel@tonic-gate } posix_spawnattr_t;
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate typedef struct {
677c478bd9Sstevel@tonic-gate 	void *__file_attrp;	/* implementation-private */
687c478bd9Sstevel@tonic-gate } posix_spawn_file_actions_t;
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate #if defined(__STDC__)
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate extern int posix_spawn(
737c478bd9Sstevel@tonic-gate 	pid_t *_RESTRICT_KYWD pid,
747c478bd9Sstevel@tonic-gate 	const char *_RESTRICT_KYWD path,
757c478bd9Sstevel@tonic-gate 	const posix_spawn_file_actions_t *file_actions,
767c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
777c478bd9Sstevel@tonic-gate 	char *const argv[_RESTRICT_KYWD],
787c478bd9Sstevel@tonic-gate 	char *const envp[_RESTRICT_KYWD]);
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate extern int posix_spawnp(
817c478bd9Sstevel@tonic-gate 	pid_t *_RESTRICT_KYWD pid,
827c478bd9Sstevel@tonic-gate 	const char *_RESTRICT_KYWD file,
837c478bd9Sstevel@tonic-gate 	const posix_spawn_file_actions_t *file_actions,
847c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
857c478bd9Sstevel@tonic-gate 	char *const argv[_RESTRICT_KYWD],
867c478bd9Sstevel@tonic-gate 	char *const envp[_RESTRICT_KYWD]);
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_init(
897c478bd9Sstevel@tonic-gate 	posix_spawn_file_actions_t *file_actions);
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_destroy(
927c478bd9Sstevel@tonic-gate 	posix_spawn_file_actions_t *file_actions);
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_addopen(
957c478bd9Sstevel@tonic-gate 	posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
967c478bd9Sstevel@tonic-gate 	int filedes,
977c478bd9Sstevel@tonic-gate 	const char *_RESTRICT_KYWD path,
987c478bd9Sstevel@tonic-gate 	int oflag,
997c478bd9Sstevel@tonic-gate 	mode_t mode);
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_addclose(
1027c478bd9Sstevel@tonic-gate 	posix_spawn_file_actions_t *file_actions,
1037c478bd9Sstevel@tonic-gate 	int filedes);
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_adddup2(
1067c478bd9Sstevel@tonic-gate 	posix_spawn_file_actions_t *file_actions,
1077c478bd9Sstevel@tonic-gate 	int filedes,
1087c478bd9Sstevel@tonic-gate 	int newfiledes);
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate extern int posix_spawnattr_init(
1117c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *attr);
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate extern int posix_spawnattr_destroy(
1147c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *attr);
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setflags(
1177c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *attr,
1187c478bd9Sstevel@tonic-gate 	short flags);
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getflags(
1217c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1227c478bd9Sstevel@tonic-gate 	short *_RESTRICT_KYWD flags);
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setpgroup(
1257c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *attr,
1267c478bd9Sstevel@tonic-gate 	pid_t pgroup);
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getpgroup(
1297c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1307c478bd9Sstevel@tonic-gate 	pid_t *_RESTRICT_KYWD pgroup);
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setschedparam(
1337c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *_RESTRICT_KYWD attr,
1347c478bd9Sstevel@tonic-gate 	const struct sched_param *_RESTRICT_KYWD schedparam);
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getschedparam(
1377c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1387c478bd9Sstevel@tonic-gate 	struct sched_param *_RESTRICT_KYWD schedparam);
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setschedpolicy(
1417c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *attr,
1427c478bd9Sstevel@tonic-gate 	int schedpolicy);
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getschedpolicy(
1457c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1467c478bd9Sstevel@tonic-gate 	int *_RESTRICT_KYWD schedpolicy);
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setsigdefault(
1497c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *_RESTRICT_KYWD attr,
1507c478bd9Sstevel@tonic-gate 	const sigset_t *_RESTRICT_KYWD sigdefault);
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getsigdefault(
1537c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1547c478bd9Sstevel@tonic-gate 	sigset_t *_RESTRICT_KYWD sigdefault);
1557c478bd9Sstevel@tonic-gate 
15603bc411dSRoger A. Faulkner /*
15703bc411dSRoger A. Faulkner  * non-portable Solaris extensions
15803bc411dSRoger A. Faulkner  */
15903bc411dSRoger A. Faulkner #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
16003bc411dSRoger A. Faulkner 
161*462453d2SMatthew Ahrens extern int posix_spawn_pipe_np(
162*462453d2SMatthew Ahrens 	pid_t *_RESTRICT_KYWD pidp,
163*462453d2SMatthew Ahrens 	int *_RESTRICT_KYWD fdp,
164*462453d2SMatthew Ahrens 	const char *_RESTRICT_KYWD cmd,
165*462453d2SMatthew Ahrens 	boolean_t write,
166*462453d2SMatthew Ahrens 	posix_spawn_file_actions_t *_RESTRICT_KYWD fact,
167*462453d2SMatthew Ahrens 	posix_spawnattr_t *_RESTRICT_KYWD attr);
168*462453d2SMatthew Ahrens 
16908556f6cSRoger A. Faulkner extern int posix_spawn_file_actions_addclosefrom_np(
17008556f6cSRoger A. Faulkner 	posix_spawn_file_actions_t *file_actions,
17108556f6cSRoger A. Faulkner 	int lowfiledes);
17208556f6cSRoger A. Faulkner 
17303bc411dSRoger A. Faulkner extern int posix_spawnattr_setsigignore_np(
17403bc411dSRoger A. Faulkner 	posix_spawnattr_t *_RESTRICT_KYWD attr,
17503bc411dSRoger A. Faulkner 	const sigset_t *_RESTRICT_KYWD sigignore);
17603bc411dSRoger A. Faulkner 
17703bc411dSRoger A. Faulkner extern int posix_spawnattr_getsigignore_np(
17803bc411dSRoger A. Faulkner 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
17903bc411dSRoger A. Faulkner 	sigset_t *_RESTRICT_KYWD sigignore);
18003bc411dSRoger A. Faulkner 
18103bc411dSRoger A. Faulkner #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
18203bc411dSRoger A. Faulkner 
1837c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setsigmask(
1847c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *_RESTRICT_KYWD attr,
1857c478bd9Sstevel@tonic-gate 	const sigset_t *_RESTRICT_KYWD sigmask);
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getsigmask(
1887c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1897c478bd9Sstevel@tonic-gate 	sigset_t *_RESTRICT_KYWD sigmask);
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate #else	/* __STDC__ */
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate extern int posix_spawn();
1947c478bd9Sstevel@tonic-gate extern int posix_spawnp();
1957c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_init();
1967c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_destroy();
1977c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_addopen();
1987c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_addclose();
1997c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_adddup2();
2007c478bd9Sstevel@tonic-gate extern int posix_spawnattr_init();
2017c478bd9Sstevel@tonic-gate extern int posix_spawnattr_destroy();
2027c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setflags();
2037c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getflags();
2047c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setpgroup();
2057c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getpgroup();
2067c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setschedparam();
2077c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getschedparam();
2087c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setschedpolicy();
2097c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getschedpolicy();
2107c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setsigdefault();
2117c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getsigdefault();
21203bc411dSRoger A. Faulkner #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
213*462453d2SMatthew Ahrens extern int posix_spawn_pipe_np();
21408556f6cSRoger A. Faulkner extern int posix_spawn_file_actions_addclosefrom_np();
21503bc411dSRoger A. Faulkner extern int posix_spawnattr_setsigignore_np();
21603bc411dSRoger A. Faulkner extern int posix_spawnattr_getsigignore_np();
21703bc411dSRoger A. Faulkner #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
2187c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setsigmask();
2197c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getsigmask();
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2247c478bd9Sstevel@tonic-gate }
2257c478bd9Sstevel@tonic-gate #endif
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate #endif	/* _SPAWN_H */
228