Skip to content

Instantly share code, notes, and snippets.

@psimonyi
Created September 17, 2014 21:12
Show Gist options
  • Save psimonyi/2b7a62a163b1452f57c4 to your computer and use it in GitHub Desktop.
Save psimonyi/2b7a62a163b1452f57c4 to your computer and use it in GitHub Desktop.
Forkbomb testing service
#include <unistd.h>
int main() {
while (1) fork();
}
# This service is for conveniently testing your own forkbombs.
# Don't expect it to do real security.
# 1. Update the ExecStart line to your own executable path.
# 2. Install (e.g. symlink) as /etc/systemd/system/forkbomb.service
# 3. sudo systemctl start forkbomb.service
# 4. Verify lots of processes. Optionally, view the log with journalctl.
# 5. sudo systemctl stop forkbomb.service
# 6. Resume computing with sanity intact.
[Unit]
Description=Forkbomb tester
[Service]
CPUShares=100
MemoryLimit=1M
LimitNPROC=100
CapabilityBoundingSet=~CAP_SYS_RESOURCE
NoNewPrivileges=true
KillSignal=SIGKILL
StandardOutput=journal
User=nobody
ExecStart=/home/psimonyi/tmp/forkbomb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment