xref: /freebsd/usr.bin/protect/protect.1 (revision 0957b409)
1.\" Copyright (c) 2013 Hudson River Trading LLC
2.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd September 19, 2013
29.Dt PROTECT 1
30.Os
31.Sh NAME
32.Nm protect
33.Nd "protect processes from being killed when swap space is exhausted"
34.Sh SYNOPSIS
35.Nm
36.Op Fl i
37.Ar command
38.Nm
39.Op Fl cdi
40.Fl g Ar pgrp | Fl p Ar pid
41.Sh DESCRIPTION
42The
43.Nm
44command is used to mark processes as protected.
45The kernel does not kill protected processes when swap space is exhausted.
46Note that this protected state is not inherited by child processes by default.
47.Pp
48The options are:
49.Bl -tag -width XXXXXXXXXX
50.It Fl c
51Remove protection from the specified processes.
52.It Fl d
53Apply the operation to all current children of the specified processes.
54.It Fl i
55Apply the operation to all future children of the specified processes.
56.It Fl g Ar pgrp
57Apply the operation to all processes in the specified process group.
58.It Fl p Ar pid
59Apply the operation to the specified process.
60.It Ar command
61Execute
62.Ar command
63as a protected process.
64.El
65.Pp
66Note that only one of the
67.Fl p
68or
69.Fl g
70flags may be specified when adjusting the state of existing processes.
71.Sh EXIT STATUS
72.Ex -std
73.Sh EXAMPLES
74Mark the Xorg server as protected:
75.Pp
76.Dl "pgrep Xorg | xargs protect -p"
77.Pp
78Protect all ssh sessions and their child processes:
79.Pp
80.Dl "pgrep sshd | xargs protect -dip"
81.Pp
82Remove protection from all current and future processes:
83.Pp
84.Dl "protect -cdi -p 1"
85.Sh SEE ALSO
86.Xr procctl 2
87.Sh BUGS
88If you protect a runaway process that allocates all memory the system will
89deadlock.
90