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