1 /* 2 * Copyright 2017 Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SPAWN_H_ 6 #define _SPAWN_H_ 7 8 9 #include <sched.h> 10 #include <signal.h> 11 #include <stdint.h> 12 #include <sys/types.h> 13 14 15 /* 16 * Flags for spawn attributes. 17 */ 18 #define POSIX_SPAWN_RESETIDS 0x01 19 #define POSIX_SPAWN_SETPGROUP 0x02 20 #if 0 /* Unimplemented flags: */ 21 #define POSIX_SPAWN_SETSCHEDPARAM 0x04 22 #define POSIX_SPAWN_SETSCHEDULER 0x08 23 #endif /* 0 */ 24 #define POSIX_SPAWN_SETSIGDEF 0x10 25 #define POSIX_SPAWN_SETSIGMASK 0x20 26 #define POSIX_SPAWN_SETSID 0x40 27 28 29 typedef struct _posix_spawnattr *posix_spawnattr_t; 30 typedef struct _posix_spawn_file_actions *posix_spawn_file_actions_t; 31 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 38 extern int posix_spawn(pid_t *pid, const char *path, 39 const posix_spawn_file_actions_t *file_actions, 40 const posix_spawnattr_t *attrp, char *const argv[], char *const envp[]); 41 extern int posix_spawnp(pid_t *pid, const char *file, 42 const posix_spawn_file_actions_t *file_actions, 43 const posix_spawnattr_t *attrp, char *const argv[], 44 char *const envp[]); 45 46 /* file actions functions */ 47 extern int posix_spawn_file_actions_init( 48 posix_spawn_file_actions_t *file_actions); 49 extern int posix_spawn_file_actions_destroy( 50 posix_spawn_file_actions_t *file_actions); 51 extern int posix_spawn_file_actions_addopen( 52 posix_spawn_file_actions_t *file_actions, 53 int fildes, const char *path, int oflag, mode_t mode); 54 extern int posix_spawn_file_actions_addclose( 55 posix_spawn_file_actions_t *file_actions, int fildes); 56 extern int posix_spawn_file_actions_adddup2( 57 posix_spawn_file_actions_t *file_actions, int fildes, int newfildes); 58 59 /* spawn attribute functions */ 60 extern int posix_spawnattr_destroy(posix_spawnattr_t *attr); 61 extern int posix_spawnattr_init(posix_spawnattr_t *attr); 62 extern int posix_spawnattr_getflags(const posix_spawnattr_t *attr, 63 short *_flags); 64 extern int posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags); 65 extern int posix_spawnattr_getpgroup(const posix_spawnattr_t *attr, 66 pid_t *_pgroup); 67 extern int posix_spawnattr_setpgroup(posix_spawnattr_t *attr, pid_t pgroup); 68 extern int posix_spawnattr_getsigdefault(const posix_spawnattr_t *attr, 69 sigset_t *sigdefault); 70 extern int posix_spawnattr_setsigdefault(posix_spawnattr_t *attr, 71 const sigset_t *sigdefault); 72 extern int posix_spawnattr_getsigmask(const posix_spawnattr_t *attr, 73 sigset_t *_sigmask); 74 extern int posix_spawnattr_setsigmask(posix_spawnattr_t *attr, 75 const sigset_t *sigmask); 76 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 83 #endif /* _SPAWN_H_ */ 84 85