procctl.h revision 277698
1296781Sdes/*-
276259Sgreen * Copyright (c) 2013 Advanced Computing Technologies LLC
376259Sgreen * Written by: John H. Baldwin <jhb@FreeBSD.org>
476259Sgreen * All rights reserved.
576259Sgreen *
676259Sgreen * Redistribution and use in source and binary forms, with or without
776259Sgreen * modification, are permitted provided that the following conditions
876259Sgreen * are met:
976259Sgreen * 1. Redistributions of source code must retain the above copyright
1076259Sgreen *    notice, this list of conditions and the following disclaimer.
1176259Sgreen * 2. Redistributions in binary form must reproduce the above copyright
1276259Sgreen *    notice, this list of conditions and the following disclaimer in the
1376259Sgreen *    documentation and/or other materials provided with the distribution.
1476259Sgreen *
1576259Sgreen * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1676259Sgreen * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1776259Sgreen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1876259Sgreen * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1976259Sgreen * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2076259Sgreen * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2176259Sgreen * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2276259Sgreen * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2376259Sgreen * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2476259Sgreen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2576259Sgreen * SUCH DAMAGE.
2676259Sgreen *
2776259Sgreen * $FreeBSD: stable/10/sys/sys/procctl.h 277698 2015-01-25 13:15:12Z kib $
2876259Sgreen */
2976259Sgreen
3076259Sgreen#ifndef	_SYS_PROCCTL_H_
3176259Sgreen#define	_SYS_PROCCTL_H_
3276259Sgreen
3376259Sgreen#ifndef _KERNEL
3476259Sgreen#include <sys/types.h>
3576259Sgreen#include <sys/wait.h>
3676259Sgreen#endif
3776259Sgreen
3876259Sgreen#define	PROC_SPROTECT		1	/* set protected state */
3976259Sgreen#define	PROC_REAP_ACQUIRE	2	/* reaping enable */
4076259Sgreen#define	PROC_REAP_RELEASE	3	/* reaping disable */
4176259Sgreen#define	PROC_REAP_STATUS	4	/* reaping status */
4276259Sgreen#define	PROC_REAP_GETPIDS	5	/* get descendants */
4376259Sgreen#define	PROC_REAP_KILL		6	/* kill descendants */
44162856Sdes#define	PROC_TRACE_CTL		7	/* en/dis ptrace and coredumps */
45162856Sdes#define	PROC_TRACE_STATUS	8	/* query tracing status */
46162856Sdes
47162856Sdes/* Operations for PROC_SPROTECT (passed in integer arg). */
48162856Sdes#define	PPROT_OP(x)	((x) & 0xf)
49162856Sdes#define	PPROT_SET	1
50162856Sdes#define	PPROT_CLEAR	2
51162856Sdes
52162856Sdes/* Flags for PROC_SPROTECT (ORed in with operation). */
53162856Sdes#define	PPROT_FLAGS(x)	((x) & ~0xf)
54162856Sdes#define	PPROT_DESCEND	0x10
55162856Sdes#define	PPROT_INHERIT	0x20
56295367Sdes
57162856Sdes/* Result of PREAP_STATUS (returned by value). */
5898941Sdesstruct procctl_reaper_status {
59137019Sdes	u_int	rs_flags;
60137019Sdes	u_int	rs_children;
61295367Sdes	u_int	rs_descendants;
62137019Sdes	pid_t	rs_reaper;
6376259Sgreen	pid_t	rs_pid;
64137019Sdes	u_int	rs_pad0[15];
65137019Sdes};
66137019Sdes
6776259Sgreen/* struct procctl_reaper_status rs_flags */
6876259Sgreen#define	REAPER_STATUS_OWNED	0x00000001
6976259Sgreen#define	REAPER_STATUS_REALINIT	0x00000002
7076259Sgreen
7176259Sgreenstruct procctl_reaper_pidinfo {
72162856Sdes	pid_t	pi_pid;
7376259Sgreen	pid_t	pi_subtree;
74162856Sdes	u_int	pi_flags;
7576259Sgreen	u_int	pi_pad0[15];
76128460Sdes};
7776259Sgreen
78128460Sdes#define	REAPER_PIDINFO_VALID	0x00000001
79128460Sdes#define	REAPER_PIDINFO_CHILD	0x00000002
80162856Sdes
8176259Sgreenstruct procctl_reaper_pids {
8276259Sgreen	u_int	rp_count;
8376259Sgreen	u_int	rp_pad0[15];
84137019Sdes	struct procctl_reaper_pidinfo *rp_pids;
85137019Sdes};
86137019Sdes
87137019Sdesstruct procctl_reaper_kill {
88137019Sdes	int	rk_sig;		/* in  - signal to send */
89137019Sdes	u_int	rk_flags;	/* in  - REAPER_KILL flags */
90197679Sdes	pid_t	rk_subtree;	/* in  - subtree, if REAPER_KILL_SUBTREE */
91295367Sdes	u_int	rk_killed;	/* out - count of processes sucessfully
92137019Sdes				   killed */
93137019Sdes	pid_t	rk_fpid;	/* out - first failed pid for which error
94137019Sdes				   is returned */
95137019Sdes	u_int	rk_pad0[15];
96137019Sdes};
97197679Sdes
98197679Sdes#define	REAPER_KILL_CHILDREN	0x00000001
99197679Sdes#define	REAPER_KILL_SUBTREE	0x00000002
100197679Sdes
101255767Sdes#define	PROC_TRACE_CTL_ENABLE		1
102197679Sdes#define	PROC_TRACE_CTL_DISABLE		2
103197679Sdes#define	PROC_TRACE_CTL_DISABLE_EXEC	3
104137019Sdes
105137019Sdes#ifndef _KERNEL
106137019Sdes__BEGIN_DECLS
107137019Sdesint	procctl(idtype_t, id_t, int, void *);
108137019Sdes__END_DECLS
109181111Sdes
110137019Sdes#endif
111137019Sdes
112137019Sdes#endif /* !_SYS_PROCCTL_H_ */
113137019Sdes