procset.h revision 297077
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28/*	  All Rights Reserved  	*/
29
30
31#ifndef _SYS_PROCSET_H
32#define	_SYS_PROCSET_H
33
34#pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.6 */
35
36#ifdef	__cplusplus
37extern "C" {
38#endif
39
40#include <sys/feature_tests.h>
41#include <sys/types.h>
42#include <sys/signal.h>
43
44/*
45 *	This file defines the data needed to specify a set of
46 *	processes.  These types are used by the sigsend, sigsendset,
47 *	priocntl, priocntlset, waitid, evexit, and evexitset system
48 *	calls.
49 */
50#define	P_INITPID	1
51#define	P_INITUID	0
52#define	P_INITPGID	0
53
54#ifndef _IDTYPE_T_DECLARED
55
56/*
57 *	The following defines the values for an identifier type.  It
58 *	specifies the interpretation of an id value.  An idtype and
59 *	id together define a simple set of processes.
60 */
61typedef enum
62#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
63	idtype		/* pollutes XPG4.2 namespace */
64#endif
65		{
66	P_PID,		/* A process identifier.		*/
67	P_PPID,		/* A parent process identifier.		*/
68	P_PGID,		/* A process group (job control group)	*/
69			/* identifier.				*/
70	P_SID,		/* A session identifier.		*/
71	P_CID,		/* A scheduling class identifier.	*/
72	P_UID,		/* A user identifier.			*/
73	P_GID,		/* A group identifier.			*/
74	P_ALL,		/* All processes.			*/
75	P_LWPID,	/* An LWP identifier.			*/
76	P_TASKID,	/* A task identifier.			*/
77	P_PROJID,	/* A project identifier.		*/
78	P_POOLID,	/* A pool identifier.			*/
79	P_ZONEID,	/* A zone identifier.			*/
80	P_CTID,		/* A (process) contract identifier.	*/
81	P_CPUID,	/* CPU identifier.			*/
82	P_PSETID	/* Processor set identifier		*/
83} idtype_t;
84
85#define	_IDTYPE_T_DECLARED
86
87#endif
88
89/*
90 *	The following defines the operations which can be performed to
91 *	combine two simple sets of processes to form another set of
92 *	processes.
93 */
94#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
95typedef enum idop {
96	POP_DIFF,	/* Set difference.  The processes which	*/
97			/* are in the left operand set and not	*/
98			/* in the right operand set.		*/
99	POP_AND,	/* Set disjunction.  The processes	*/
100			/* which are in both the left and right	*/
101			/* operand sets.			*/
102	POP_OR,		/* Set conjunction.  The processes	*/
103			/* which are in either the left or the	*/
104			/* right operand sets (or both).	*/
105	POP_XOR		/* Set exclusive or.  The processes 	*/
106			/* which are in either the left or	*/
107			/* right operand sets but not in both.	*/
108} idop_t;
109
110
111/*
112 *	The following structure is used to define a set of processes.
113 *	The set is defined in terms of two simple sets of processes
114 *	and an operator which operates on these two operand sets.
115 */
116typedef struct procset {
117	idop_t		p_op;	/* The operator connection the	*/
118				/* following two operands each	*/
119				/* of which is a simple set of	*/
120				/* processes.			*/
121
122	idtype_t	p_lidtype;
123				/* The type of the left operand	*/
124				/* simple set.			*/
125	id_t		p_lid;	/* The id of the left operand.	*/
126
127	idtype_t	p_ridtype;
128				/* The type of the right	*/
129				/* operand simple set.		*/
130	id_t		p_rid;	/* The id of the right operand.	*/
131} procset_t;
132
133/*
134 *	The following macro can be used to initialize a procset_t
135 *	structure.
136 */
137#define	setprocset(psp, op, ltype, lid, rtype, rid) \
138			(psp)->p_op		= (op); \
139			(psp)->p_lidtype	= (ltype); \
140			(psp)->p_lid		= (lid); \
141			(psp)->p_ridtype	= (rtype); \
142			(psp)->p_rid		= (rid);
143
144#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
145
146#ifdef illumos
147#ifdef _KERNEL
148
149struct proc;
150
151extern int dotoprocs(procset_t *, int (*)(), char *);
152extern int dotolwp(procset_t *, int (*)(), char *);
153extern int procinset(struct proc *, procset_t *);
154extern int sigsendproc(struct proc *, sigsend_t *);
155extern int sigsendset(procset_t *, sigsend_t *);
156extern boolean_t cur_inset_only(procset_t *);
157extern id_t getmyid(idtype_t);
158
159#endif	/* _KERNEL */
160#endif
161
162#ifdef	__cplusplus
163}
164#endif
165
166#endif	/* _SYS_PROCSET_H */
167