| 1 | /** @file
|
|---|
| 2 | * GLIBC 2.3.2
|
|---|
| 3 | * @changed bird: we don't have sched.h or the GLIBC standard definitions.
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /* Definitions for POSIX spawn interface.
|
|---|
| 7 | Copyright (C) 2000 Free Software Foundation, Inc.
|
|---|
| 8 | This file is part of the GNU C Library.
|
|---|
| 9 |
|
|---|
| 10 | The GNU C Library is free software; you can redistribute it and/or
|
|---|
| 11 | modify it under the terms of the GNU Lesser General Public
|
|---|
| 12 | License as published by the Free Software Foundation; either
|
|---|
| 13 | version 2.1 of the License, or (at your option) any later version.
|
|---|
| 14 |
|
|---|
| 15 | The GNU C Library is distributed in the hope that it will be useful,
|
|---|
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 18 | Lesser General Public License for more details.
|
|---|
| 19 |
|
|---|
| 20 | You should have received a copy of the GNU Lesser General Public
|
|---|
| 21 | License along with the GNU C Library; if not, write to the Free
|
|---|
| 22 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|---|
| 23 | 02111-1307 USA. */
|
|---|
| 24 |
|
|---|
| 25 | #ifndef _SPAWN_H
|
|---|
| 26 | #define _SPAWN_H 1
|
|---|
| 27 |
|
|---|
| 28 | #include <features.h>
|
|---|
| 29 | #ifndef __EMX__ /* bird */
|
|---|
| 30 | #include <sched.h>
|
|---|
| 31 | #endif /* bird */
|
|---|
| 32 | #include <signal.h>
|
|---|
| 33 | #include <sys/types.h>
|
|---|
| 34 |
|
|---|
| 35 | /* bird - start */
|
|---|
| 36 | #ifdef __EMX__
|
|---|
| 37 |
|
|---|
| 38 | #ifndef __THROW
|
|---|
| 39 | #define __THROW
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 42 | /* GCC 2.95 and later have "__restrict"; C99 compilers have
|
|---|
| 43 | "restrict", and "configure" may have defined "restrict". */
|
|---|
| 44 | #ifndef __restrict
|
|---|
| 45 | # if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
|
|---|
| 46 | # if defined restrict || 199901L <= __STDC_VERSION__
|
|---|
| 47 | # define __restrict restrict
|
|---|
| 48 | # else
|
|---|
| 49 | # define __restrict
|
|---|
| 50 | # endif
|
|---|
| 51 | # endif
|
|---|
| 52 | #endif
|
|---|
| 53 |
|
|---|
| 54 | /* GCC 3.1 and later support declaring arrays as non-overlapping
|
|---|
| 55 | using the syntax array_name[restrict] */
|
|---|
| 56 | #ifndef __restrict_arr
|
|---|
| 57 | # if ! (3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) || defined (__GNUG__)
|
|---|
| 58 | # define __restrict_arr
|
|---|
| 59 | # else
|
|---|
| 60 | # define __restrict_arr __restrict
|
|---|
| 61 | # endif
|
|---|
| 62 | #endif
|
|---|
| 63 |
|
|---|
| 64 | /** @todo implement sched.h */
|
|---|
| 65 | struct sched_param {
|
|---|
| 66 | int sched_priority;
|
|---|
| 67 | };
|
|---|
| 68 | #define SCHED_FIFO 1
|
|---|
| 69 | #define SCHED_OTHER 2
|
|---|
| 70 | #define SCHED_RR 3
|
|---|
| 71 |
|
|---|
| 72 | #endif
|
|---|
| 73 | /* bird - end */
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 | /* Data structure to contain attributes for thread creation. */
|
|---|
| 77 | typedef struct
|
|---|
| 78 | {
|
|---|
| 79 | short int __flags;
|
|---|
| 80 | pid_t __pgrp;
|
|---|
| 81 | sigset_t __sd;
|
|---|
| 82 | sigset_t __ss;
|
|---|
| 83 | struct sched_param __sp;
|
|---|
| 84 | int __policy;
|
|---|
| 85 | int __pad[16];
|
|---|
| 86 | } posix_spawnattr_t;
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | /* Data structure to contain information about the actions to be
|
|---|
| 90 | performed in the new process with respect to file descriptors. */
|
|---|
| 91 | typedef struct
|
|---|
| 92 | {
|
|---|
| 93 | int __allocated;
|
|---|
| 94 | int __used;
|
|---|
| 95 | struct __spawn_action *__actions;
|
|---|
| 96 | int __pad[16];
|
|---|
| 97 | } posix_spawn_file_actions_t;
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 | /* Flags to be set in the `posix_spawnattr_t'. */
|
|---|
| 101 | #define POSIX_SPAWN_RESETIDS 0x01
|
|---|
| 102 | #define POSIX_SPAWN_SETPGROUP 0x02
|
|---|
| 103 | #define POSIX_SPAWN_SETSIGDEF 0x04
|
|---|
| 104 | #define POSIX_SPAWN_SETSIGMASK 0x08
|
|---|
| 105 | #define POSIX_SPAWN_SETSCHEDPARAM 0x10
|
|---|
| 106 | #define POSIX_SPAWN_SETSCHEDULER 0x20
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 | __BEGIN_DECLS
|
|---|
| 110 |
|
|---|
| 111 | /* Spawn a new process executing PATH with the attributes describes in *ATTRP.
|
|---|
| 112 | Before running the process perform the actions described in FILE-ACTIONS. */
|
|---|
| 113 | extern int posix_spawn (pid_t *__restrict __pid,
|
|---|
| 114 | __const char *__restrict __path,
|
|---|
| 115 | __const posix_spawn_file_actions_t *__restrict
|
|---|
| 116 | __file_actions,
|
|---|
| 117 | __const posix_spawnattr_t *__restrict __attrp,
|
|---|
| 118 | char *__const argv[__restrict_arr],
|
|---|
| 119 | char *__const envp[__restrict_arr]) __THROW;
|
|---|
| 120 |
|
|---|
| 121 | /* Similar to `posix_spawn' but search for FILE in the PATH. */
|
|---|
| 122 | extern int posix_spawnp (pid_t *__pid, __const char *__file,
|
|---|
| 123 | __const posix_spawn_file_actions_t *__file_actions,
|
|---|
| 124 | __const posix_spawnattr_t *__attrp,
|
|---|
| 125 | char *__const argv[], char *__const envp[]) __THROW;
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 | /* Initialize data structure with attributes for `spawn' to default values. */
|
|---|
| 129 | extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW;
|
|---|
| 130 |
|
|---|
| 131 | /* Free resources associated with ATTR. */
|
|---|
| 132 | extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW;
|
|---|
| 133 |
|
|---|
| 134 | /* Store signal mask for signals with default handling from ATTR in
|
|---|
| 135 | SIGDEFAULT. */
|
|---|
| 136 | extern int posix_spawnattr_getsigdefault (__const posix_spawnattr_t *
|
|---|
| 137 | __restrict __attr,
|
|---|
| 138 | sigset_t *__restrict __sigdefault)
|
|---|
| 139 | __THROW;
|
|---|
| 140 |
|
|---|
| 141 | /* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */
|
|---|
| 142 | extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *__restrict __attr,
|
|---|
| 143 | __const sigset_t *__restrict
|
|---|
| 144 | __sigdefault)
|
|---|
| 145 | __THROW;
|
|---|
| 146 |
|
|---|
| 147 | /* Store signal mask for the new process from ATTR in SIGMASK. */
|
|---|
| 148 | extern int posix_spawnattr_getsigmask (__const posix_spawnattr_t *__restrict
|
|---|
| 149 | __attr,
|
|---|
| 150 | sigset_t *__restrict __sigmask) __THROW;
|
|---|
| 151 |
|
|---|
| 152 | /* Set signal mask for the new process in ATTR to SIGMASK. */
|
|---|
| 153 | extern int posix_spawnattr_setsigmask (posix_spawnattr_t *__restrict __attr,
|
|---|
| 154 | __const sigset_t *__restrict __sigmask)
|
|---|
| 155 | __THROW;
|
|---|
| 156 |
|
|---|
| 157 | /* Get flag word from the attribute structure. */
|
|---|
| 158 | extern int posix_spawnattr_getflags (__const posix_spawnattr_t *__restrict
|
|---|
| 159 | __attr,
|
|---|
| 160 | short int *__restrict __flags) __THROW;
|
|---|
| 161 |
|
|---|
| 162 | /* Store flags in the attribute structure. */
|
|---|
| 163 | extern int posix_spawnattr_setflags (posix_spawnattr_t *_attr,
|
|---|
| 164 | short int __flags) __THROW;
|
|---|
| 165 |
|
|---|
| 166 | /* Get process group ID from the attribute structure. */
|
|---|
| 167 | extern int posix_spawnattr_getpgroup (__const posix_spawnattr_t *__restrict
|
|---|
| 168 | __attr, pid_t *__restrict __pgroup)
|
|---|
| 169 | __THROW;
|
|---|
| 170 |
|
|---|
| 171 | /* Store process group ID in the attribute structure. */
|
|---|
| 172 | extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr,
|
|---|
| 173 | pid_t __pgroup) __THROW;
|
|---|
| 174 |
|
|---|
| 175 | /* Get scheduling policy from the attribute structure. */
|
|---|
| 176 | extern int posix_spawnattr_getschedpolicy (__const posix_spawnattr_t *
|
|---|
| 177 | __restrict __attr,
|
|---|
| 178 | int *__restrict __schedpolicy)
|
|---|
| 179 | __THROW;
|
|---|
| 180 |
|
|---|
| 181 | /* Store scheduling policy in the attribute structure. */
|
|---|
| 182 | extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
|
|---|
| 183 | int __schedpolicy) __THROW;
|
|---|
| 184 |
|
|---|
| 185 | /* Get scheduling parameters from the attribute structure. */
|
|---|
| 186 | extern int posix_spawnattr_getschedparam (__const posix_spawnattr_t *
|
|---|
| 187 | __restrict __attr,
|
|---|
| 188 | struct sched_param *__restrict
|
|---|
| 189 | __schedparam) __THROW;
|
|---|
| 190 |
|
|---|
| 191 | /* Store scheduling parameters in the attribute structure. */
|
|---|
| 192 | extern int posix_spawnattr_setschedparam (posix_spawnattr_t *__restrict __attr,
|
|---|
| 193 | const struct sched_param *
|
|---|
| 194 | __restrict __schedparam) __THROW;
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | /* Initialize data structure for file attribute for `spawn' call. */
|
|---|
| 198 | extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *
|
|---|
| 199 | __file_actions) __THROW;
|
|---|
| 200 |
|
|---|
| 201 | /* Free resources associated with FILE-ACTIONS. */
|
|---|
| 202 | extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *
|
|---|
| 203 | __file_actions) __THROW;
|
|---|
| 204 |
|
|---|
| 205 | /* Add an action to FILE-ACTIONS which tells the implementation to call
|
|---|
| 206 | `open' for the given file during the `spawn' call. */
|
|---|
| 207 | extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *
|
|---|
| 208 | __restrict __file_actions,
|
|---|
| 209 | int __fd,
|
|---|
| 210 | __const char *__restrict __path,
|
|---|
| 211 | int __oflag, mode_t __mode)
|
|---|
| 212 | __THROW;
|
|---|
| 213 |
|
|---|
| 214 | /* Add an action to FILE-ACTIONS which tells the implementation to call
|
|---|
| 215 | `close' for the given file descriptor during the `spawn' call. */
|
|---|
| 216 | extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *
|
|---|
| 217 | __file_actions, int __fd)
|
|---|
| 218 | __THROW;
|
|---|
| 219 |
|
|---|
| 220 | /* Add an action to FILE-ACTIONS which tells the implementation to call
|
|---|
| 221 | `dup2' for the given file descriptors during the `spawn' call. */
|
|---|
| 222 | extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *
|
|---|
| 223 | __file_actions,
|
|---|
| 224 | int __fd, int __newfd) __THROW;
|
|---|
| 225 |
|
|---|
| 226 | __END_DECLS
|
|---|
| 227 |
|
|---|
| 228 | #endif /* spawn.h */
|
|---|