Skip to content

Instantly share code, notes, and snippets.

@medigor
Created May 12, 2023 21:28
Show Gist options
  • Save medigor/4338da72e886c09ee3825793a52dce38 to your computer and use it in GitHub Desktop.
Save medigor/4338da72e886c09ee3825793a52dce38 to your computer and use it in GitHub Desktop.
use std::{
fs::File,
io::Write,
os::fd::{FromRawFd, IntoRawFd},
};
fn main() {
let mut f = unsafe { File::from_raw_fd(0) };
f.write_all(b"Hello, world!\n").unwrap();
//std::mem::forget(f);
f.into_raw_fd();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment