1da2e3ebdSchin 2da2e3ebdSchin /* : : generated by proto : : */ 3da2e3ebdSchin /*********************************************************************** 4da2e3ebdSchin * * 5da2e3ebdSchin * This software is part of the ast package * 6*3e14f97fSRoger A. Faulkner * Copyright (c) 1985-2010 AT&T Intellectual Property * 7da2e3ebdSchin * and is licensed under the * 8da2e3ebdSchin * Common Public License, Version 1.0 * 97c2fbfb3SApril Chin * by AT&T Intellectual Property * 10da2e3ebdSchin * * 11da2e3ebdSchin * A copy of the License is available at * 12da2e3ebdSchin * http://www.opensource.org/licenses/cpl1.0.txt * 13da2e3ebdSchin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 14da2e3ebdSchin * * 15da2e3ebdSchin * Information and Software Systems Research * 16da2e3ebdSchin * AT&T Research * 17da2e3ebdSchin * Florham Park NJ * 18da2e3ebdSchin * * 19da2e3ebdSchin * Glenn Fowler <gsf@research.att.com> * 20da2e3ebdSchin * David Korn <dgk@research.att.com> * 21da2e3ebdSchin * Phong Vo <kpv@research.att.com> * 22da2e3ebdSchin * * 23da2e3ebdSchin ***********************************************************************/ 24da2e3ebdSchin 25da2e3ebdSchin 26da2e3ebdSchin /* 27da2e3ebdSchin * process library interface 28da2e3ebdSchin */ 29da2e3ebdSchin 30da2e3ebdSchin #ifndef _PROC_H 31da2e3ebdSchin #if !defined(__PROTO__) 32da2e3ebdSchin #include <prototyped.h> 33da2e3ebdSchin #endif 34da2e3ebdSchin #if !defined(__LINKAGE__) 35da2e3ebdSchin #define __LINKAGE__ /* 2004-08-11 transition */ 36da2e3ebdSchin #endif 37da2e3ebdSchin 38da2e3ebdSchin #define _PROC_H 39da2e3ebdSchin 40da2e3ebdSchin #include <ast.h> 41da2e3ebdSchin 42da2e3ebdSchin #define PROC_ARGMOD (1<<0) /* argv[-1],argv[0] can be modified */ 43da2e3ebdSchin #define PROC_BACKGROUND (1<<1) /* shell background (&) setup */ 447c2fbfb3SApril Chin #define PROC_CHECK (1<<17) /* check that command exists */ 45da2e3ebdSchin #define PROC_CLEANUP (1<<2) /* close parent redirect fds on error */ 46da2e3ebdSchin #define PROC_DAEMON (1<<3) /* daemon setup */ 47da2e3ebdSchin #define PROC_ENVCLEAR (1<<4) /* clear environment */ 48da2e3ebdSchin #define PROC_FOREGROUND (1<<14) /* system(3) setup */ 49da2e3ebdSchin #define PROC_GID (1<<5) /* setgid(getgid()) */ 50da2e3ebdSchin #define PROC_IGNORE (1<<6) /* ignore parent pipe errors */ 517c2fbfb3SApril Chin #define PROC_IGNOREPATH (1<<16) /* procrun() intercept to ignore path */ 52da2e3ebdSchin #define PROC_OVERLAY (1<<7) /* overlay current process if possible */ 53da2e3ebdSchin #define PROC_PARANOID (1<<8) /* restrict everything */ 54da2e3ebdSchin #define PROC_PRIVELEGED (1<<9) /* setuid(0), setgid(getegid()) */ 55da2e3ebdSchin #define PROC_READ (1<<10) /* proc pipe fd 1 returned */ 56da2e3ebdSchin #define PROC_SESSION (1<<11) /* session leader */ 57da2e3ebdSchin #define PROC_UID (1<<12) /* setuid(getuid()) */ 58da2e3ebdSchin #define PROC_WRITE (1<<13) /* proc pipe fd 0 returned */ 59da2e3ebdSchin #define PROC_ZOMBIE (1<<15) /* proc may leave a zombie behind */ 60da2e3ebdSchin 61da2e3ebdSchin #define PROC_ARG_BIT 14 /* bits per op arg */ 62da2e3ebdSchin #define PROC_OP_BIT 4 /* bits per op */ 63da2e3ebdSchin 64da2e3ebdSchin #define PROC_ARG_NULL ((1<<PROC_ARG_BIT)-1) 65da2e3ebdSchin 66da2e3ebdSchin #define PROC_fd_dup 0x4 67da2e3ebdSchin #define PROC_FD_CHILD 0x1 68da2e3ebdSchin #define PROC_FD_PARENT 0x2 69da2e3ebdSchin 70da2e3ebdSchin #define PROC_sig_dfl 0x8 71da2e3ebdSchin #define PROC_sig_ign 0x9 72da2e3ebdSchin 73da2e3ebdSchin #define PROC_sys_pgrp 0xa 74da2e3ebdSchin #define PROC_sys_umask 0xb 75da2e3ebdSchin 76da2e3ebdSchin #define PROC_op1(o,a) (((o)<<(2*PROC_ARG_BIT))|((a)&((PROC_ARG_NULL<<PROC_ARG_BIT)|PROC_ARG_NULL))) 77da2e3ebdSchin #define PROC_op2(o,a,b) (((o)<<(2*PROC_ARG_BIT))|(((b)&PROC_ARG_NULL)<<PROC_ARG_BIT)|((a)&PROC_ARG_NULL)) 78da2e3ebdSchin 79da2e3ebdSchin #define PROC_FD_CLOSE(p,f) PROC_op2(PROC_fd_dup|(f),p,PROC_ARG_NULL) 80da2e3ebdSchin #define PROC_FD_DUP(p,c,f) PROC_op2(PROC_fd_dup|(f),p,c) 81da2e3ebdSchin #define PROC_SIG_DFL(s) PROC_op1(PROC_sig_dfl,s,0) 82da2e3ebdSchin #define PROC_SIG_IGN(s) PROC_op1(PROC_sig_ign,s,0) 83da2e3ebdSchin #define PROC_SYS_PGRP(g) PROC_op1(PROC_sys_pgrp,g) 84da2e3ebdSchin #define PROC_SYS_UMASK(m) PROC_op1(PROC_sys_umask,m,0) 85da2e3ebdSchin 86da2e3ebdSchin #define PROC_OP(x) (((x)>>(2*PROC_ARG_BIT))&((1<<PROC_OP_BIT)-1)) 87da2e3ebdSchin #define PROC_ARG(x,n) ((n)?(((x)>>(((n)-1)*PROC_ARG_BIT))&PROC_ARG_NULL):(((x)&~((1<<(2*PROC_ARG_BIT))-1))==~((1<<(2*PROC_ARG_BIT))-1))?(-1):((x)&~((1<<(2*PROC_ARG_BIT))-1))) 88da2e3ebdSchin 89da2e3ebdSchin typedef struct 90da2e3ebdSchin { 91da2e3ebdSchin pid_t pid; /* process id */ 92da2e3ebdSchin pid_t pgrp; /* process group id */ 93da2e3ebdSchin int rfd; /* read fd if applicable */ 94da2e3ebdSchin int wfd; /* write fd if applicable */ 95da2e3ebdSchin 96da2e3ebdSchin #ifdef _PROC_PRIVATE_ 97da2e3ebdSchin _PROC_PRIVATE_ 98da2e3ebdSchin #endif 99da2e3ebdSchin 100da2e3ebdSchin } Proc_t; 101da2e3ebdSchin 102da2e3ebdSchin #if _BLD_ast && defined(__EXPORT__) 103da2e3ebdSchin #undef __MANGLE__ 104da2e3ebdSchin #define __MANGLE__ __LINKAGE__ __EXPORT__ 105da2e3ebdSchin #endif 106da2e3ebdSchin 107da2e3ebdSchin extern __MANGLE__ int procclose __PROTO__((Proc_t*)); 108da2e3ebdSchin extern __MANGLE__ int procfree __PROTO__((Proc_t*)); 1097c2fbfb3SApril Chin extern __MANGLE__ Proc_t* procopen __PROTO__((const char*, char**, char**, long*, int)); 1107c2fbfb3SApril Chin extern __MANGLE__ int procrun __PROTO__((const char*, char**, int)); 111da2e3ebdSchin 112da2e3ebdSchin #undef __MANGLE__ 113da2e3ebdSchin #define __MANGLE__ __LINKAGE__ 114da2e3ebdSchin 115da2e3ebdSchin #endif 116