1 #ifndef _AST_SPAWNVEX_H 2 #define _AST_SPAWNVEX_H 1 3 4 #if USE_SPAWN 5 6 #include <fcntl.h> 7 #include <inttypes.h> 8 #include <limits.h> 9 #include <locale.h> 10 #include <stddef.h> 11 #include <stdint.h> 12 #include <stdlib.h> 13 #include <sys/types.h> 14 #include <unistd.h> 15 16 union _Spawnvex_u; 17 typedef union _Spawnvex_u Spawnvex_u; 18 19 typedef struct Spawnvex_s { 20 unsigned int cur; 21 int io; 22 unsigned int max; 23 unsigned int set; 24 unsigned int flags; 25 unsigned int frame; 26 pid_t pgrp; 27 int debug; 28 int noexec; 29 Spawnvex_u *op; 30 } Spawnvex_t; 31 32 typedef struct Spawnvex_noexec_s { 33 Spawnvex_t *vex; /* caller vex handle */ 34 void *handle; /* caller callback handle */ 35 const char *path; /* spawnvex() path */ 36 char *const *argv; /* spawnvex() argv */ 37 char *const *envv; /* spawnvex() envv */ 38 unsigned int flags; /* SPAWN_EXEC */ 39 int msgfd; /* if no return and >= 0 close */ 40 } Spawnvex_noexec_t; 41 42 typedef int (*Spawnvex_f)(void *, uint64_t, uint64_t); 43 44 // #define SPAWN_BACKGROUND 0x00001 45 #define SPAWN_CLEANUP 0x00002 46 // #define SPAWN_DAEMON 0x00004 47 #define SPAWN_DEBUG 0x00008 48 #define SPAWN_EXEC 0x00010 49 #define SPAWN_FLUSH 0x00020 50 #define SPAWN_FOREGROUND 0x00040 51 #define SPAWN_FRAME 0x00100 52 #define SPAWN_NOCALL 0x00200 53 // #define SPAWN_ORPHAN 0x00400 54 // #define SPAWN_OVERLAY 0x00800 55 // #define SPAWN_READ 0x01000 56 #define SPAWN_RESET 0x02000 57 #define SPAWN_UNDO 0x08000 58 // #define SPAWN_WRITE 0x10000 59 // #define SPAWN_ZOMBIE 0x20000 60 61 #define SPAWN_noop (-1) 62 #define SPAWN_cwd (-2) 63 #define SPAWN_frame (-3) 64 #define SPAWN_noexec (-4) 65 #define SPAWN_pgrp (-5) 66 #define SPAWN_resetids (-6) 67 #define SPAWN_sid (-7) 68 #define SPAWN_sigdef (-8) 69 #define SPAWN_sigmask (-9) 70 #define SPAWN_truncate (-10) 71 #define SPAWN_umask (-11) 72 73 extern pid_t spawnveg(const char *, char *const[], char *const[], pid_t); 74 extern pid_t spawnvex(const char *, char *const[], char *const[], Spawnvex_t *); 75 extern Spawnvex_t *spawnvex_open(unsigned int); 76 extern int spawnvex_add(Spawnvex_t *, int64_t, int64_t, Spawnvex_f, void *); 77 extern int spawnvex_apply(Spawnvex_t *, int, int); 78 extern int64_t spawnvex_get(Spawnvex_t *, int, int); 79 extern int spawnvex_close(Spawnvex_t *); 80 81 #endif // USE_SPAWN 82 83 #endif 84