Skip to content

Instantly share code, notes, and snippets.

@cameroncros
Created July 8, 2024 00:23
Show Gist options
  • Save cameroncros/8ae3def101efc08be2cd69846d9dcc81 to your computer and use it in GitHub Desktop.
Save cameroncros/8ae3def101efc08be2cd69846d9dcc81 to your computer and use it in GitHub Desktop.
Rust program to generate 1000 orphan/defunct processes.
[package]
name = "orphanage"
version = "0.1.0"
edition = "2021"
[dependencies]
fork = "0.1.23"
use std::process::exit;
use std::thread::sleep;
use std::time::Duration;
use fork::{Fork, fork};
fn main() {
for _ in 0..1000 {
if let Ok(Fork::Child) = fork() {
exit(0);
}
}
sleep(Duration::from_secs(30));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment