PROTECT(1)
π protect(1) β keep ur faves alive when swap says bye π
okay bestie, welcome to PROTECT(1) from the General Commands Manual. This is the page about marking processes as protected so the kernel doesn't just yeet them when swap space runs out. Iconic survival behavior, honestly. π«Ά
β¨ NAME β¨
protect β protect processes from being killed when swap space is exhausted
πΈ SYNOPSIS πΈ
protect [-i] command
protect [-cdi] -g pgrp
protect [-cdi] -p pid
π¦ DESCRIPTION π¦
The protect command is literally here to mark processes as protected. When swap space is exhausted, the kernel does not kill protected processes. That's the whole vibe. π
Heads up bestie: this protected state is not inherited by child processes by default. So don't assume the baby processes get the same armor for free. π
The options are:
-cβ remove protection from the specified processes. rip their little safety bubble π-dβ apply the operation to all current children of the specified processes.-iβ apply the operation to all future children of the specified processes.-gpgrp β apply the operation to all processes in the specified process group.-ppid β apply the operation to the specified process.- command β execute command as a protected process. main character energy from the jump β¨
Also note: when you're adjusting the state of existing processes, you may specify only one of-por-g. Don't try to do both, bestie, it's not that kind of party.
Daemons can be protected on startup using the β¨nameβ©_oomprotect option from rc.conf(5). Cute, right? π
π EXIT STATUS π
The protect utility exits 0 on success, and >0 if an error occurs. Slay when it works, side-eye when it doesn't. π
π EXAMPLES π
Mark the Xorg server as protected:
pgrep Xorg | xargs protect -p
Protect all ssh sessions and their child processes:
pgrep sshd | xargs protect -dip
Remove protection from all current and future processes:
protect -cdi -p 1
Using ps(1) to check if the protect flag has been applied to the process:
ps -O flags,flags2 -p 64430
PID F F2 TT STAT TIME COMMAND
64430 10104002 00000001 5 S+ 0:00.00 ./main
^P ^PI
In the above example, P points at the protected flag and PI points at the inheritance flag. The process is protected if the P bit is set to 1. All children of this process will also be protected if the PI bit is set to 1. iykyk π
π₯ DIAGNOSTICS π₯
protect: procctl: Operation not permitted
The protect command does not have the required permissions to protect selected processes. There are many reasons why this could be the case, e.g.:
protectis not executed byroot.protectis executed inside ajail(8), which is not supported at the moment.
So yeah, if you're not root or you're in jail, this is giving nope. π
β SEE ALSO β
π BUGS π
If you protect a runaway process that allocates all memory, the system will deadlock.
bestie that is not a vibe. do not do that. π«Ά
this iconic little page is PROTECT(1), General Commands Manual, from the Debian crew β dated July 12, 2022. mwah πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2013 Hudson River Trading LLC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms