xref: /titanic_50/usr/src/head/spawn.h (revision 657b1f3d64bcf8eaa2385dba72a6047f089433b2)
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
5*657b1f3dSraf  * Common Development and Distribution License (the "License").
6*657b1f3dSraf  * 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  */
21*657b1f3dSraf 
227c478bd9Sstevel@tonic-gate /*
23*657b1f3dSraf  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef _SPAWN_H
287c478bd9Sstevel@tonic-gate #define	_SPAWN_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate #include <signal.h>
357c478bd9Sstevel@tonic-gate #include <sched.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
41*657b1f3dSraf /*
42*657b1f3dSraf  * flags for posix_spawnattr_setflags()
43*657b1f3dSraf  */
44*657b1f3dSraf #define	POSIX_SPAWN_RESETIDS		0x0001
45*657b1f3dSraf #define	POSIX_SPAWN_SETPGROUP		0x0002
46*657b1f3dSraf #define	POSIX_SPAWN_SETSIGDEF		0x0004
47*657b1f3dSraf #define	POSIX_SPAWN_SETSIGMASK		0x0008
48*657b1f3dSraf #define	POSIX_SPAWN_SETSCHEDPARAM	0x0010
49*657b1f3dSraf #define	POSIX_SPAWN_SETSCHEDULER	0x0020
50*657b1f3dSraf /*
51*657b1f3dSraf  * non-portable Solaris extensions
52*657b1f3dSraf  */
53*657b1f3dSraf #define	POSIX_SPAWN_NOSIGCHLD_NP	0x1000
54*657b1f3dSraf #define	POSIX_SPAWN_WAITPID_NP		0x2000
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate typedef struct {
577c478bd9Sstevel@tonic-gate 	void *__spawn_attrp;	/* implementation-private */
587c478bd9Sstevel@tonic-gate } posix_spawnattr_t;
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate typedef struct {
617c478bd9Sstevel@tonic-gate 	void *__file_attrp;	/* implementation-private */
627c478bd9Sstevel@tonic-gate } posix_spawn_file_actions_t;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate #if defined(__STDC__)
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate extern int posix_spawn(
677c478bd9Sstevel@tonic-gate 	pid_t *_RESTRICT_KYWD pid,
687c478bd9Sstevel@tonic-gate 	const char *_RESTRICT_KYWD path,
697c478bd9Sstevel@tonic-gate 	const posix_spawn_file_actions_t *file_actions,
707c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
717c478bd9Sstevel@tonic-gate 	char *const argv[_RESTRICT_KYWD],
727c478bd9Sstevel@tonic-gate 	char *const envp[_RESTRICT_KYWD]);
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate extern int posix_spawnp(
757c478bd9Sstevel@tonic-gate 	pid_t *_RESTRICT_KYWD pid,
767c478bd9Sstevel@tonic-gate 	const char *_RESTRICT_KYWD file,
777c478bd9Sstevel@tonic-gate 	const posix_spawn_file_actions_t *file_actions,
787c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
797c478bd9Sstevel@tonic-gate 	char *const argv[_RESTRICT_KYWD],
807c478bd9Sstevel@tonic-gate 	char *const envp[_RESTRICT_KYWD]);
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_init(
837c478bd9Sstevel@tonic-gate 	posix_spawn_file_actions_t *file_actions);
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_destroy(
867c478bd9Sstevel@tonic-gate 	posix_spawn_file_actions_t *file_actions);
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_addopen(
897c478bd9Sstevel@tonic-gate 	posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
907c478bd9Sstevel@tonic-gate 	int filedes,
917c478bd9Sstevel@tonic-gate 	const char *_RESTRICT_KYWD path,
927c478bd9Sstevel@tonic-gate 	int oflag,
937c478bd9Sstevel@tonic-gate 	mode_t mode);
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_addclose(
967c478bd9Sstevel@tonic-gate 	posix_spawn_file_actions_t *file_actions,
977c478bd9Sstevel@tonic-gate 	int filedes);
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_adddup2(
1007c478bd9Sstevel@tonic-gate 	posix_spawn_file_actions_t *file_actions,
1017c478bd9Sstevel@tonic-gate 	int filedes,
1027c478bd9Sstevel@tonic-gate 	int newfiledes);
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate extern int posix_spawnattr_init(
1057c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *attr);
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate extern int posix_spawnattr_destroy(
1087c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *attr);
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setflags(
1117c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *attr,
1127c478bd9Sstevel@tonic-gate 	short flags);
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getflags(
1157c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1167c478bd9Sstevel@tonic-gate 	short *_RESTRICT_KYWD flags);
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setpgroup(
1197c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *attr,
1207c478bd9Sstevel@tonic-gate 	pid_t pgroup);
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getpgroup(
1237c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1247c478bd9Sstevel@tonic-gate 	pid_t *_RESTRICT_KYWD pgroup);
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setschedparam(
1277c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *_RESTRICT_KYWD attr,
1287c478bd9Sstevel@tonic-gate 	const struct sched_param *_RESTRICT_KYWD schedparam);
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getschedparam(
1317c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1327c478bd9Sstevel@tonic-gate 	struct sched_param *_RESTRICT_KYWD schedparam);
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setschedpolicy(
1357c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *attr,
1367c478bd9Sstevel@tonic-gate 	int schedpolicy);
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getschedpolicy(
1397c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1407c478bd9Sstevel@tonic-gate 	int *_RESTRICT_KYWD schedpolicy);
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setsigdefault(
1437c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *_RESTRICT_KYWD attr,
1447c478bd9Sstevel@tonic-gate 	const sigset_t *_RESTRICT_KYWD sigdefault);
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getsigdefault(
1477c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1487c478bd9Sstevel@tonic-gate 	sigset_t *_RESTRICT_KYWD sigdefault);
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setsigmask(
1517c478bd9Sstevel@tonic-gate 	posix_spawnattr_t *_RESTRICT_KYWD attr,
1527c478bd9Sstevel@tonic-gate 	const sigset_t *_RESTRICT_KYWD sigmask);
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getsigmask(
1557c478bd9Sstevel@tonic-gate 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
1567c478bd9Sstevel@tonic-gate 	sigset_t *_RESTRICT_KYWD sigmask);
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate #else	/* __STDC__ */
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate extern int posix_spawn();
1617c478bd9Sstevel@tonic-gate extern int posix_spawnp();
1627c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_init();
1637c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_destroy();
1647c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_addopen();
1657c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_addclose();
1667c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_adddup2();
1677c478bd9Sstevel@tonic-gate extern int posix_spawnattr_init();
1687c478bd9Sstevel@tonic-gate extern int posix_spawnattr_destroy();
1697c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setflags();
1707c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getflags();
1717c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setpgroup();
1727c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getpgroup();
1737c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setschedparam();
1747c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getschedparam();
1757c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setschedpolicy();
1767c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getschedpolicy();
1777c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setsigdefault();
1787c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getsigdefault();
1797c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setsigmask();
1807c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getsigmask();
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1857c478bd9Sstevel@tonic-gate }
1867c478bd9Sstevel@tonic-gate #endif
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate #endif	/* _SPAWN_H */
189