Created
July 8, 2024 00:23
-
-
Save cameroncros/8ae3def101efc08be2cd69846d9dcc81 to your computer and use it in GitHub Desktop.
Rust program to generate 1000 orphan/defunct processes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "orphanage" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
fork = "0.1.23" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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