protect.1 (416ba5c74546f32a993436a99516d35008e9f384) protect.1 (c8b6be0f7d1b92d11b279761685f61f6702700a1)
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

--- 11 unchanged lines hidden (view full) ---

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.\"
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

--- 11 unchanged lines hidden (view full) ---

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
28.Dd May 18, 2021
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

--- 26 unchanged lines hidden (view full) ---

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.
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

--- 26 unchanged lines hidden (view full) ---

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.Pp
72Daemons can be protected on startup using
73.Ao Ar name Ac Ns Va _oomprotect
74option from
75.Xr rc.conf 5 .
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"
76.Sh EXIT STATUS
77.Ex -std
78.Sh EXAMPLES
79Mark the Xorg server as protected:
80.Pp
81.Dl "pgrep Xorg | xargs protect -p"
82.Pp
83Protect all ssh sessions and their child processes:
84.Pp
85.Dl "pgrep sshd | xargs protect -dip"
86.Pp
87Remove protection from all current and future processes:
88.Pp
89.Dl "protect -cdi -p 1"
90.Pp
91Using
92.Xr ps 1
93to check if the protect flag has been applied to the process:
94.Pp
95.Dl "ps -O flags,flags2 -p 64430"
96.Pp
97.Dl " PID F F2 TT STAT TIME COMMAND"
98.Dl "64430 10104002 00000001 5 S+ 0:00.00 ./main"
99.Dl " ^P ^PI"
100.Pp
101In the above example
102.Nm P
103points at the protected flag and
104.Nm PI
105points at the iheritance flag.
106The process is protected if
107.Nm P
108bit is set to 1. All children of this process will also be protected if
109.Nm PI
110bit is set to 1.
85.Sh SEE ALSO
111.Sh SEE ALSO
86.Xr procctl 2
112.Xr ps 1 ,
113.Xr procctl 2 ,
114.Xr rc.conf 5
87.Sh BUGS
88If you protect a runaway process that allocates all memory the system will
89deadlock.
115.Sh BUGS
116If you protect a runaway process that allocates all memory the system will
117deadlock.