Home | History | Annotate | Download | only in head
      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 2009 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_spawn_file_actions_addclosefrom_np(
    158 	posix_spawn_file_actions_t *file_actions,
    159 	int lowfiledes);
    160 
    161 extern int posix_spawnattr_setsigignore_np(
    162 	posix_spawnattr_t *_RESTRICT_KYWD attr,
    163 	const sigset_t *_RESTRICT_KYWD sigignore);
    164 
    165 extern int posix_spawnattr_getsigignore_np(
    166 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
    167 	sigset_t *_RESTRICT_KYWD sigignore);
    168 
    169 #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
    170 
    171 extern int posix_spawnattr_setsigmask(
    172 	posix_spawnattr_t *_RESTRICT_KYWD attr,
    173 	const sigset_t *_RESTRICT_KYWD sigmask);
    174 
    175 extern int posix_spawnattr_getsigmask(
    176 	const posix_spawnattr_t *_RESTRICT_KYWD attr,
    177 	sigset_t *_RESTRICT_KYWD sigmask);
    178 
    179 #else	/* __STDC__ */
    180 
    181 extern int posix_spawn();
    182 extern int posix_spawnp();
    183 extern int posix_spawn_file_actions_init();
    184 extern int posix_spawn_file_actions_destroy();
    185 extern int posix_spawn_file_actions_addopen();
    186 extern int posix_spawn_file_actions_addclose();
    187 extern int posix_spawn_file_actions_adddup2();
    188 extern int posix_spawnattr_init();
    189 extern int posix_spawnattr_destroy();
    190 extern int posix_spawnattr_setflags();
    191 extern int posix_spawnattr_getflags();
    192 extern int posix_spawnattr_setpgroup();
    193 extern int posix_spawnattr_getpgroup();
    194 extern int posix_spawnattr_setschedparam();
    195 extern int posix_spawnattr_getschedparam();
    196 extern int posix_spawnattr_setschedpolicy();
    197 extern int posix_spawnattr_getschedpolicy();
    198 extern int posix_spawnattr_setsigdefault();
    199 extern int posix_spawnattr_getsigdefault();
    200 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
    201 extern int posix_spawn_file_actions_addclosefrom_np();
    202 extern int posix_spawnattr_setsigignore_np();
    203 extern int posix_spawnattr_getsigignore_np();
    204 #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
    205 extern int posix_spawnattr_setsigmask();
    206 extern int posix_spawnattr_getsigmask();
    207 
    208 #endif	/* __STDC__ */
    209 
    210 #ifdef	__cplusplus
    211 }
    212 #endif
    213 
    214 #endif	/* _SPAWN_H */
    215