mandoc: update to 1.14.1
[unleashed.git] / include / spawn.h
blobba8cbdc30691e7de674157b4919318c73b069fd4
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
30 * Copyright (c) 2011 by Delphix. All rights reserved.
33 #ifndef _SPAWN_H
34 #define _SPAWN_H
36 #include <sys/feature_tests.h>
37 #include <sys/types.h>
38 #include <signal.h>
39 #include <sched.h>
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
46 * flags for posix_spawnattr_setflags()
48 #define POSIX_SPAWN_RESETIDS 0x0001
49 #define POSIX_SPAWN_SETPGROUP 0x0002
50 #define POSIX_SPAWN_SETSIGDEF 0x0004
51 #define POSIX_SPAWN_SETSIGMASK 0x0008
52 #define POSIX_SPAWN_SETSCHEDPARAM 0x0010
53 #define POSIX_SPAWN_SETSCHEDULER 0x0020
55 * non-portable Solaris extensions
57 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
58 #define POSIX_SPAWN_SETSIGIGN_NP 0x0800
59 #define POSIX_SPAWN_NOSIGCHLD_NP 0x1000
60 #define POSIX_SPAWN_WAITPID_NP 0x2000
61 #define POSIX_SPAWN_NOEXECERR_NP 0x4000
62 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
64 typedef struct {
65 void *__spawn_attrp; /* implementation-private */
66 } posix_spawnattr_t;
68 typedef struct {
69 void *__file_attrp; /* implementation-private */
70 } posix_spawn_file_actions_t;
72 extern int posix_spawn(
73 pid_t *_RESTRICT_KYWD pid,
74 const char *_RESTRICT_KYWD path,
75 const posix_spawn_file_actions_t *file_actions,
76 const posix_spawnattr_t *_RESTRICT_KYWD attrp,
77 char *const *_RESTRICT_KYWD argv,
78 char *const *_RESTRICT_KYWD envp);
80 extern int posix_spawnp(
81 pid_t *_RESTRICT_KYWD pid,
82 const char *_RESTRICT_KYWD file,
83 const posix_spawn_file_actions_t *file_actions,
84 const posix_spawnattr_t *_RESTRICT_KYWD attrp,
85 char *const *_RESTRICT_KYWD argv,
86 char *const *_RESTRICT_KYWD envp);
88 extern int posix_spawn_file_actions_init(
89 posix_spawn_file_actions_t *file_actions);
91 extern int posix_spawn_file_actions_destroy(
92 posix_spawn_file_actions_t *file_actions);
94 extern int posix_spawn_file_actions_addopen(
95 posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
96 int filedes,
97 const char *_RESTRICT_KYWD path,
98 int oflag,
99 mode_t mode);
101 extern int posix_spawn_file_actions_addclose(
102 posix_spawn_file_actions_t *file_actions,
103 int filedes);
105 extern int posix_spawn_file_actions_adddup2(
106 posix_spawn_file_actions_t *file_actions,
107 int filedes,
108 int newfiledes);
110 extern int posix_spawnattr_init(
111 posix_spawnattr_t *attr);
113 extern int posix_spawnattr_destroy(
114 posix_spawnattr_t *attr);
116 extern int posix_spawnattr_setflags(
117 posix_spawnattr_t *attr,
118 short flags);
120 extern int posix_spawnattr_getflags(
121 const posix_spawnattr_t *_RESTRICT_KYWD attr,
122 short *_RESTRICT_KYWD flags);
124 extern int posix_spawnattr_setpgroup(
125 posix_spawnattr_t *attr,
126 pid_t pgroup);
128 extern int posix_spawnattr_getpgroup(
129 const posix_spawnattr_t *_RESTRICT_KYWD attr,
130 pid_t *_RESTRICT_KYWD pgroup);
132 extern int posix_spawnattr_setschedparam(
133 posix_spawnattr_t *_RESTRICT_KYWD attr,
134 const struct sched_param *_RESTRICT_KYWD schedparam);
136 extern int posix_spawnattr_getschedparam(
137 const posix_spawnattr_t *_RESTRICT_KYWD attr,
138 struct sched_param *_RESTRICT_KYWD schedparam);
140 extern int posix_spawnattr_setschedpolicy(
141 posix_spawnattr_t *attr,
142 int schedpolicy);
144 extern int posix_spawnattr_getschedpolicy(
145 const posix_spawnattr_t *_RESTRICT_KYWD attr,
146 int *_RESTRICT_KYWD schedpolicy);
148 extern int posix_spawnattr_setsigdefault(
149 posix_spawnattr_t *_RESTRICT_KYWD attr,
150 const sigset_t *_RESTRICT_KYWD sigdefault);
152 extern int posix_spawnattr_getsigdefault(
153 const posix_spawnattr_t *_RESTRICT_KYWD attr,
154 sigset_t *_RESTRICT_KYWD sigdefault);
157 * non-portable Solaris extensions
159 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
161 extern int posix_spawn_pipe_np(
162 pid_t *_RESTRICT_KYWD pidp,
163 int *_RESTRICT_KYWD fdp,
164 const char *_RESTRICT_KYWD cmd,
165 boolean_t write,
166 posix_spawn_file_actions_t *_RESTRICT_KYWD fact,
167 posix_spawnattr_t *_RESTRICT_KYWD attr);
169 extern int posix_spawn_file_actions_addclosefrom_np(
170 posix_spawn_file_actions_t *file_actions,
171 int lowfiledes);
173 extern int posix_spawnattr_setsigignore_np(
174 posix_spawnattr_t *_RESTRICT_KYWD attr,
175 const sigset_t *_RESTRICT_KYWD sigignore);
177 extern int posix_spawnattr_getsigignore_np(
178 const posix_spawnattr_t *_RESTRICT_KYWD attr,
179 sigset_t *_RESTRICT_KYWD sigignore);
181 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
183 extern int posix_spawnattr_setsigmask(
184 posix_spawnattr_t *_RESTRICT_KYWD attr,
185 const sigset_t *_RESTRICT_KYWD sigmask);
187 extern int posix_spawnattr_getsigmask(
188 const posix_spawnattr_t *_RESTRICT_KYWD attr,
189 sigset_t *_RESTRICT_KYWD sigmask);
191 #ifdef __cplusplus
193 #endif
195 #endif /* _SPAWN_H */