Back to index

glibc  2.9
spawn.h
Go to the documentation of this file.
00001 /* Definitions for POSIX spawn interface.
00002    Copyright (C) 2000, 2003, 2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef       _SPAWN_H
00021 #define       _SPAWN_H      1
00022 
00023 #include <features.h>
00024 #include <sched.h>
00025 #include <signal.h>
00026 #include <sys/types.h>
00027 
00028 
00029 /* Data structure to contain attributes for thread creation.  */
00030 typedef struct
00031 {
00032   short int __flags;
00033   pid_t __pgrp;
00034   sigset_t __sd;
00035   sigset_t __ss;
00036   struct sched_param __sp;
00037   int __policy;
00038   int __pad[16];
00039 } posix_spawnattr_t;
00040 
00041 
00042 /* Data structure to contain information about the actions to be
00043    performed in the new process with respect to file descriptors.  */
00044 typedef struct
00045 {
00046   int __allocated;
00047   int __used;
00048   struct __spawn_action *__actions;
00049   int __pad[16];
00050 } posix_spawn_file_actions_t;
00051 
00052 
00053 /* Flags to be set in the `posix_spawnattr_t'.  */
00054 #define POSIX_SPAWN_RESETIDS              0x01
00055 #define POSIX_SPAWN_SETPGROUP             0x02
00056 #define POSIX_SPAWN_SETSIGDEF             0x04
00057 #define POSIX_SPAWN_SETSIGMASK            0x08
00058 #define POSIX_SPAWN_SETSCHEDPARAM  0x10
00059 #define POSIX_SPAWN_SETSCHEDULER   0x20
00060 #ifdef __USE_GNU
00061 # define POSIX_SPAWN_USEVFORK             0x40
00062 #endif
00063 
00064 
00065 __BEGIN_DECLS
00066 
00067 /* Spawn a new process executing PATH with the attributes describes in *ATTRP.
00068    Before running the process perform the actions described in FILE-ACTIONS.
00069 
00070    This function is a possible cancellation points and therefore not
00071    marked with __THROW. */
00072 extern int posix_spawn (pid_t *__restrict __pid,
00073                      __const char *__restrict __path,
00074                      __const posix_spawn_file_actions_t *__restrict
00075                      __file_actions,
00076                      __const posix_spawnattr_t *__restrict __attrp,
00077                      char *__const argv[__restrict_arr],
00078                      char *__const envp[__restrict_arr]);
00079 
00080 /* Similar to `posix_spawn' but search for FILE in the PATH.
00081 
00082    This function is a possible cancellation points and therefore not
00083    marked with __THROW.  */
00084 extern int posix_spawnp (pid_t *__pid, __const char *__file,
00085                       __const posix_spawn_file_actions_t *__file_actions,
00086                       __const posix_spawnattr_t *__attrp,
00087                       char *__const argv[], char *__const envp[]);
00088 
00089 
00090 /* Initialize data structure with attributes for `spawn' to default values.  */
00091 extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW;
00092 
00093 /* Free resources associated with ATTR.  */
00094 extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW;
00095 
00096 /* Store signal mask for signals with default handling from ATTR in
00097    SIGDEFAULT.  */
00098 extern int posix_spawnattr_getsigdefault (__const posix_spawnattr_t *
00099                                      __restrict __attr,
00100                                      sigset_t *__restrict __sigdefault)
00101      __THROW;
00102 
00103 /* Set signal mask for signals with default handling in ATTR to SIGDEFAULT.  */
00104 extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *__restrict __attr,
00105                                      __const sigset_t *__restrict
00106                                      __sigdefault)
00107      __THROW;
00108 
00109 /* Store signal mask for the new process from ATTR in SIGMASK.  */
00110 extern int posix_spawnattr_getsigmask (__const posix_spawnattr_t *__restrict
00111                                    __attr,
00112                                    sigset_t *__restrict __sigmask) __THROW;
00113 
00114 /* Set signal mask for the new process in ATTR to SIGMASK.  */
00115 extern int posix_spawnattr_setsigmask (posix_spawnattr_t *__restrict __attr,
00116                                    __const sigset_t *__restrict __sigmask)
00117      __THROW;
00118 
00119 /* Get flag word from the attribute structure.  */
00120 extern int posix_spawnattr_getflags (__const posix_spawnattr_t *__restrict
00121                                  __attr,
00122                                  short int *__restrict __flags) __THROW;
00123 
00124 /* Store flags in the attribute structure.  */
00125 extern int posix_spawnattr_setflags (posix_spawnattr_t *_attr,
00126                                  short int __flags) __THROW;
00127 
00128 /* Get process group ID from the attribute structure.  */
00129 extern int posix_spawnattr_getpgroup (__const posix_spawnattr_t *__restrict
00130                                   __attr, pid_t *__restrict __pgroup)
00131      __THROW;
00132 
00133 /* Store process group ID in the attribute structure.  */
00134 extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr,
00135                                   pid_t __pgroup) __THROW;
00136 
00137 /* Get scheduling policy from the attribute structure.  */
00138 extern int posix_spawnattr_getschedpolicy (__const posix_spawnattr_t *
00139                                       __restrict __attr,
00140                                       int *__restrict __schedpolicy)
00141      __THROW;
00142 
00143 /* Store scheduling policy in the attribute structure.  */
00144 extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
00145                                       int __schedpolicy) __THROW;
00146 
00147 /* Get scheduling parameters from the attribute structure.  */
00148 extern int posix_spawnattr_getschedparam (__const posix_spawnattr_t *
00149                                      __restrict __attr,
00150                                      struct sched_param *__restrict
00151                                      __schedparam) __THROW;
00152 
00153 /* Store scheduling parameters in the attribute structure.  */
00154 extern int posix_spawnattr_setschedparam (posix_spawnattr_t *__restrict __attr,
00155                                      const struct sched_param *
00156                                      __restrict __schedparam) __THROW;
00157 
00158 
00159 /* Initialize data structure for file attribute for `spawn' call.  */
00160 extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *
00161                                      __file_actions) __THROW;
00162 
00163 /* Free resources associated with FILE-ACTIONS.  */
00164 extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *
00165                                         __file_actions) __THROW;
00166 
00167 /* Add an action to FILE-ACTIONS which tells the implementation to call
00168    `open' for the given file during the `spawn' call.  */
00169 extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *
00170                                         __restrict __file_actions,
00171                                         int __fd,
00172                                         __const char *__restrict __path,
00173                                         int __oflag, mode_t __mode)
00174      __THROW;
00175 
00176 /* Add an action to FILE-ACTIONS which tells the implementation to call
00177    `close' for the given file descriptor during the `spawn' call.  */
00178 extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *
00179                                          __file_actions, int __fd)
00180      __THROW;
00181 
00182 /* Add an action to FILE-ACTIONS which tells the implementation to call
00183    `dup2' for the given file descriptors during the `spawn' call.  */
00184 extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *
00185                                         __file_actions,
00186                                         int __fd, int __newfd) __THROW;
00187 
00188 __END_DECLS
00189 
00190 #endif /* spawn.h */