xref: /freebsd/usr.bin/protect/protect.1 (revision 179fa75e6e218d71a85a6b17ccc231036a148543)
1*179fa75eSJohn Baldwin.\" Copyright (c) 2013 Hudson River Trading LLC
255648840SJohn Baldwin.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
355648840SJohn Baldwin.\" All rights reserved.
455648840SJohn Baldwin.\"
555648840SJohn Baldwin.\" Redistribution and use in source and binary forms, with or without
655648840SJohn Baldwin.\" modification, are permitted provided that the following conditions
755648840SJohn Baldwin.\" are met:
855648840SJohn Baldwin.\" 1. Redistributions of source code must retain the above copyright
955648840SJohn Baldwin.\"    notice, this list of conditions and the following disclaimer.
1055648840SJohn Baldwin.\" 2. Redistributions in binary form must reproduce the above copyright
1155648840SJohn Baldwin.\"    notice, this list of conditions and the following disclaimer in the
1255648840SJohn Baldwin.\"    documentation and/or other materials provided with the distribution.
1355648840SJohn Baldwin.\"
1455648840SJohn Baldwin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1555648840SJohn Baldwin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1655648840SJohn Baldwin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1755648840SJohn Baldwin.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1855648840SJohn Baldwin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1955648840SJohn Baldwin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2055648840SJohn Baldwin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2155648840SJohn Baldwin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2255648840SJohn Baldwin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2355648840SJohn Baldwin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2455648840SJohn Baldwin.\" SUCH DAMAGE.
2555648840SJohn Baldwin.\"
2655648840SJohn Baldwin.\" $FreeBSD$
2755648840SJohn Baldwin.\"
2855648840SJohn Baldwin.Dd September 19, 2013
2955648840SJohn Baldwin.Dt PROTECT 1
3055648840SJohn Baldwin.Os
3155648840SJohn Baldwin.Sh NAME
3255648840SJohn Baldwin.Nm protect
3355648840SJohn Baldwin.Nd "protect processes from being killed when swap space is exhausted"
3455648840SJohn Baldwin.Sh SYNOPSIS
3555648840SJohn Baldwin.Nm
3655648840SJohn Baldwin.Op Fl i
3755648840SJohn Baldwin.Ar command
3855648840SJohn Baldwin.Nm
3955648840SJohn Baldwin.Op Fl cdi
4055648840SJohn Baldwin.Fl g Ar pgrp | Fl p Ar pid
4155648840SJohn Baldwin.Sh DESCRIPTION
4255648840SJohn BaldwinThe
4355648840SJohn Baldwin.Nm
4455648840SJohn Baldwincommand is used to mark processes as protected.
4555648840SJohn BaldwinThe kernel does not kill protected processes when swap space is exhausted.
4655648840SJohn BaldwinNote that this protected state is not inherited by child processes by default.
4755648840SJohn Baldwin.Pp
4855648840SJohn BaldwinThe options are:
49828378a6SJoel Dahl.Bl -tag -width XXXXXXXXXX
5055648840SJohn Baldwin.It Fl c
5155648840SJohn BaldwinRemove protection from the specified processes.
5255648840SJohn Baldwin.It Fl d
5355648840SJohn BaldwinApply the operation to all current children of the specified processes.
5455648840SJohn Baldwin.It Fl i
5555648840SJohn BaldwinApply the operation to all future children of the specified processes.
5655648840SJohn Baldwin.It Fl g Ar pgrp
5755648840SJohn BaldwinApply the operation to all processes in the specified process group.
5855648840SJohn Baldwin.It Fl p Ar pid
5955648840SJohn BaldwinApply the operation to the specified process.
6055648840SJohn Baldwin.It Ar command
6155648840SJohn BaldwinExecute
6255648840SJohn Baldwin.Ar command
6355648840SJohn Baldwinas a protected process.
6455648840SJohn Baldwin.El
6555648840SJohn Baldwin.Pp
6655648840SJohn BaldwinNote that only one of the
6755648840SJohn Baldwin.Fl p
6855648840SJohn Baldwinor
6955648840SJohn Baldwin.Fl g
7055648840SJohn Baldwinflags may be specified when adjusting the state of existing processes.
7155648840SJohn Baldwin.Sh EXIT STATUS
7255648840SJohn Baldwin.Ex -std
7355648840SJohn Baldwin.Sh EXAMPLES
7455648840SJohn BaldwinMark the Xorg server as protected:
7555648840SJohn Baldwin.Pp
7655648840SJohn Baldwin.Dl "pgrep Xorg | xargs protect -p"
77828378a6SJoel Dahl.Pp
7855648840SJohn BaldwinProtect all ssh sessions and their child processes:
7955648840SJohn Baldwin.Pp
8055648840SJohn Baldwin.Dl "pgrep sshd | xargs protect -dip"
81828378a6SJoel Dahl.Pp
8255648840SJohn BaldwinRemove protection from all current and future processes:
8355648840SJohn Baldwin.Pp
8455648840SJohn Baldwin.Dl "protect -cdi -p 1"
8555648840SJohn Baldwin.Sh SEE ALSO
869648f52cSJohn Baldwin.Xr procctl 2
8755648840SJohn Baldwin.Sh BUGS
8855648840SJohn BaldwinIf you protect a runaway process that allocates all memory the system will
8955648840SJohn Baldwindeadlock.
90