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