14887Schin 24887Schin /* : : generated by proto : : */ 34887Schin /*********************************************************************** 44887Schin * * 54887Schin * This software is part of the ast package * 6*12068SRoger.Faulkner@Oracle.COM * Copyright (c) 1985-2010 AT&T Intellectual Property * 74887Schin * and is licensed under the * 84887Schin * Common Public License, Version 1.0 * 98462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 104887Schin * * 114887Schin * A copy of the License is available at * 124887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 134887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 144887Schin * * 154887Schin * Information and Software Systems Research * 164887Schin * AT&T Research * 174887Schin * Florham Park NJ * 184887Schin * * 194887Schin * Glenn Fowler <gsf@research.att.com> * 204887Schin * David Korn <dgk@research.att.com> * 214887Schin * Phong Vo <kpv@research.att.com> * 224887Schin * * 234887Schin ***********************************************************************/ 244887Schin 254887Schin 264887Schin /* 274887Schin * process library interface 284887Schin */ 294887Schin 304887Schin #ifndef _PROC_H 314887Schin #if !defined(__PROTO__) 324887Schin #include <prototyped.h> 334887Schin #endif 344887Schin #if !defined(__LINKAGE__) 354887Schin #define __LINKAGE__ /* 2004-08-11 transition */ 364887Schin #endif 374887Schin 384887Schin #define _PROC_H 394887Schin 404887Schin #include <ast.h> 414887Schin 424887Schin #define PROC_ARGMOD (1<<0) /* argv[-1],argv[0] can be modified */ 434887Schin #define PROC_BACKGROUND (1<<1) /* shell background (&) setup */ 448462SApril.Chin@Sun.COM #define PROC_CHECK (1<<17) /* check that command exists */ 454887Schin #define PROC_CLEANUP (1<<2) /* close parent redirect fds on error */ 464887Schin #define PROC_DAEMON (1<<3) /* daemon setup */ 474887Schin #define PROC_ENVCLEAR (1<<4) /* clear environment */ 484887Schin #define PROC_FOREGROUND (1<<14) /* system(3) setup */ 494887Schin #define PROC_GID (1<<5) /* setgid(getgid()) */ 504887Schin #define PROC_IGNORE (1<<6) /* ignore parent pipe errors */ 518462SApril.Chin@Sun.COM #define PROC_IGNOREPATH (1<<16) /* procrun() intercept to ignore path */ 524887Schin #define PROC_OVERLAY (1<<7) /* overlay current process if possible */ 534887Schin #define PROC_PARANOID (1<<8) /* restrict everything */ 544887Schin #define PROC_PRIVELEGED (1<<9) /* setuid(0), setgid(getegid()) */ 554887Schin #define PROC_READ (1<<10) /* proc pipe fd 1 returned */ 564887Schin #define PROC_SESSION (1<<11) /* session leader */ 574887Schin #define PROC_UID (1<<12) /* setuid(getuid()) */ 584887Schin #define PROC_WRITE (1<<13) /* proc pipe fd 0 returned */ 594887Schin #define PROC_ZOMBIE (1<<15) /* proc may leave a zombie behind */ 604887Schin 614887Schin #define PROC_ARG_BIT 14 /* bits per op arg */ 624887Schin #define PROC_OP_BIT 4 /* bits per op */ 634887Schin 644887Schin #define PROC_ARG_NULL ((1<<PROC_ARG_BIT)-1) 654887Schin 664887Schin #define PROC_fd_dup 0x4 674887Schin #define PROC_FD_CHILD 0x1 684887Schin #define PROC_FD_PARENT 0x2 694887Schin 704887Schin #define PROC_sig_dfl 0x8 714887Schin #define PROC_sig_ign 0x9 724887Schin 734887Schin #define PROC_sys_pgrp 0xa 744887Schin #define PROC_sys_umask 0xb 754887Schin 764887Schin #define PROC_op1(o,a) (((o)<<(2*PROC_ARG_BIT))|((a)&((PROC_ARG_NULL<<PROC_ARG_BIT)|PROC_ARG_NULL))) 774887Schin #define PROC_op2(o,a,b) (((o)<<(2*PROC_ARG_BIT))|(((b)&PROC_ARG_NULL)<<PROC_ARG_BIT)|((a)&PROC_ARG_NULL)) 784887Schin 794887Schin #define PROC_FD_CLOSE(p,f) PROC_op2(PROC_fd_dup|(f),p,PROC_ARG_NULL) 804887Schin #define PROC_FD_DUP(p,c,f) PROC_op2(PROC_fd_dup|(f),p,c) 814887Schin #define PROC_SIG_DFL(s) PROC_op1(PROC_sig_dfl,s,0) 824887Schin #define PROC_SIG_IGN(s) PROC_op1(PROC_sig_ign,s,0) 834887Schin #define PROC_SYS_PGRP(g) PROC_op1(PROC_sys_pgrp,g) 844887Schin #define PROC_SYS_UMASK(m) PROC_op1(PROC_sys_umask,m,0) 854887Schin 864887Schin #define PROC_OP(x) (((x)>>(2*PROC_ARG_BIT))&((1<<PROC_OP_BIT)-1)) 874887Schin #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))) 884887Schin 894887Schin typedef struct 904887Schin { 914887Schin pid_t pid; /* process id */ 924887Schin pid_t pgrp; /* process group id */ 934887Schin int rfd; /* read fd if applicable */ 944887Schin int wfd; /* write fd if applicable */ 954887Schin 964887Schin #ifdef _PROC_PRIVATE_ 974887Schin _PROC_PRIVATE_ 984887Schin #endif 994887Schin 1004887Schin } Proc_t; 1014887Schin 1024887Schin #if _BLD_ast && defined(__EXPORT__) 1034887Schin #undef __MANGLE__ 1044887Schin #define __MANGLE__ __LINKAGE__ __EXPORT__ 1054887Schin #endif 1064887Schin 1074887Schin extern __MANGLE__ int procclose __PROTO__((Proc_t*)); 1084887Schin extern __MANGLE__ int procfree __PROTO__((Proc_t*)); 1098462SApril.Chin@Sun.COM extern __MANGLE__ Proc_t* procopen __PROTO__((const char*, char**, char**, long*, int)); 1108462SApril.Chin@Sun.COM extern __MANGLE__ int procrun __PROTO__((const char*, char**, int)); 1114887Schin 1124887Schin #undef __MANGLE__ 1134887Schin #define __MANGLE__ __LINKAGE__ 1144887Schin 1154887Schin #endif 116