1255708Sjhb/*- 2283927Sjhb * Copyright (c) 2013 Hudson River Trading LLC 3255708Sjhb * Written by: John H. Baldwin <jhb@FreeBSD.org> 4255708Sjhb * All rights reserved. 5255708Sjhb * 6255708Sjhb * Redistribution and use in source and binary forms, with or without 7255708Sjhb * modification, are permitted provided that the following conditions 8255708Sjhb * are met: 9255708Sjhb * 1. Redistributions of source code must retain the above copyright 10255708Sjhb * notice, this list of conditions and the following disclaimer. 11255708Sjhb * 2. Redistributions in binary form must reproduce the above copyright 12255708Sjhb * notice, this list of conditions and the following disclaimer in the 13255708Sjhb * documentation and/or other materials provided with the distribution. 14255708Sjhb * 15255708Sjhb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16255708Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17255708Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18255708Sjhb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19255708Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20255708Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21255708Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22255708Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23255708Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24255708Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25255708Sjhb * SUCH DAMAGE. 26255708Sjhb * 27255708Sjhb * $FreeBSD: stable/10/sys/sys/procctl.h 326397 2017-11-30 14:38:07Z kib $ 28255708Sjhb */ 29255708Sjhb 30255708Sjhb#ifndef _SYS_PROCCTL_H_ 31255708Sjhb#define _SYS_PROCCTL_H_ 32255708Sjhb 33276686Skib#ifndef _KERNEL 34276686Skib#include <sys/types.h> 35276686Skib#include <sys/wait.h> 36276686Skib#endif 37276686Skib 38255708Sjhb#define PROC_SPROTECT 1 /* set protected state */ 39276686Skib#define PROC_REAP_ACQUIRE 2 /* reaping enable */ 40276686Skib#define PROC_REAP_RELEASE 3 /* reaping disable */ 41276686Skib#define PROC_REAP_STATUS 4 /* reaping status */ 42276686Skib#define PROC_REAP_GETPIDS 5 /* get descendants */ 43276686Skib#define PROC_REAP_KILL 6 /* kill descendants */ 44277698Skib#define PROC_TRACE_CTL 7 /* en/dis ptrace and coredumps */ 45277698Skib#define PROC_TRACE_STATUS 8 /* query tracing status */ 46255708Sjhb 47255708Sjhb/* Operations for PROC_SPROTECT (passed in integer arg). */ 48255708Sjhb#define PPROT_OP(x) ((x) & 0xf) 49255708Sjhb#define PPROT_SET 1 50255708Sjhb#define PPROT_CLEAR 2 51255708Sjhb 52255708Sjhb/* Flags for PROC_SPROTECT (ORed in with operation). */ 53255708Sjhb#define PPROT_FLAGS(x) ((x) & ~0xf) 54255708Sjhb#define PPROT_DESCEND 0x10 55255708Sjhb#define PPROT_INHERIT 0x20 56255708Sjhb 57276686Skib/* Result of PREAP_STATUS (returned by value). */ 58276686Skibstruct procctl_reaper_status { 59276686Skib u_int rs_flags; 60276686Skib u_int rs_children; 61276686Skib u_int rs_descendants; 62276686Skib pid_t rs_reaper; 63276686Skib pid_t rs_pid; 64276686Skib u_int rs_pad0[15]; 65276686Skib}; 66276686Skib 67276686Skib/* struct procctl_reaper_status rs_flags */ 68276686Skib#define REAPER_STATUS_OWNED 0x00000001 69276686Skib#define REAPER_STATUS_REALINIT 0x00000002 70276686Skib 71276686Skibstruct procctl_reaper_pidinfo { 72276686Skib pid_t pi_pid; 73276686Skib pid_t pi_subtree; 74276686Skib u_int pi_flags; 75276686Skib u_int pi_pad0[15]; 76276686Skib}; 77276686Skib 78276686Skib#define REAPER_PIDINFO_VALID 0x00000001 79276686Skib#define REAPER_PIDINFO_CHILD 0x00000002 80326397Skib#define REAPER_PIDINFO_REAPER 0x00000004 81276686Skib 82276686Skibstruct procctl_reaper_pids { 83276686Skib u_int rp_count; 84276686Skib u_int rp_pad0[15]; 85276686Skib struct procctl_reaper_pidinfo *rp_pids; 86276686Skib}; 87276686Skib 88276686Skibstruct procctl_reaper_kill { 89276686Skib int rk_sig; /* in - signal to send */ 90276686Skib u_int rk_flags; /* in - REAPER_KILL flags */ 91276686Skib pid_t rk_subtree; /* in - subtree, if REAPER_KILL_SUBTREE */ 92300060Spfg u_int rk_killed; /* out - count of processes successfully 93276686Skib killed */ 94276686Skib pid_t rk_fpid; /* out - first failed pid for which error 95276686Skib is returned */ 96276686Skib u_int rk_pad0[15]; 97276686Skib}; 98276686Skib 99276686Skib#define REAPER_KILL_CHILDREN 0x00000001 100276686Skib#define REAPER_KILL_SUBTREE 0x00000002 101276686Skib 102277698Skib#define PROC_TRACE_CTL_ENABLE 1 103277698Skib#define PROC_TRACE_CTL_DISABLE 2 104277698Skib#define PROC_TRACE_CTL_DISABLE_EXEC 3 105277698Skib 106255708Sjhb#ifndef _KERNEL 107255708Sjhb__BEGIN_DECLS 108255708Sjhbint procctl(idtype_t, id_t, int, void *); 109255708Sjhb__END_DECLS 110255708Sjhb 111255708Sjhb#endif 112255708Sjhb 113255708Sjhb#endif /* !_SYS_PROCCTL_H_ */ 114