1 .\" Copyright (c) 2013 Hudson River Trading LLC
2 .\" Written by: John H. Baldwin <jhb@FreeBSD.org>
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
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.
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
31 .Nd "protect processes from being killed when swap space is exhausted"
45 command is used to mark processes as protected.
46 The kernel does not kill protected processes when swap space is exhausted.
47 Note that this protected state is not inherited by child processes by default.
50 .Bl -tag -width command
52 Remove protection from the specified processes.
54 Apply the operation to all current children of the specified processes.
56 Apply the operation to all future children of the specified processes.
58 Apply the operation to all processes in the specified process group.
60 Apply the operation to the specified process.
64 as a protected process.
67 Note that only one of the
71 flags may be specified when adjusting the state of existing processes.
73 Daemons can be protected on startup using
74 .Ao Ar name Ac Ns Va _oomprotect
80 Mark the Xorg server as protected:
82 .Dl "pgrep Xorg | xargs protect -p"
84 Protect all ssh sessions and their child processes:
86 .Dl "pgrep sshd | xargs protect -dip"
88 Remove protection from all current and future processes:
90 .Dl "protect -cdi -p 1"
94 to check if the protect flag has been applied to the process:
96 .Dl "ps -O flags,flags2 -p 64430"
98 .Dl " PID F F2 TT STAT TIME COMMAND"
99 .Dl "64430 10104002 00000001 5 S+ 0:00.00 ./main"
104 points at the protected flag and
106 points at the inheritance flag.
107 The process is protected if
110 All children of this process will also be protected if
115 .It "protect: procctl: Operation not permitted"
118 command does not have the required permissions to protect selected processes.
119 There are many reasons why this could be the case, e.g.:
123 is not executed by root.
128 which is not supported at the moment.
136 If you protect a runaway process that allocates all memory the system will