Skip to content

Instantly share code, notes, and snippets.

@jonathanbeber
Last active April 24, 2020 17:00
Show Gist options
  • Save jonathanbeber/f9ba6a6e0cc56bd9aac721d2318810a5 to your computer and use it in GitHub Desktop.
Save jonathanbeber/f9ba6a6e0cc56bd9aac721d2318810a5 to your computer and use it in GitHub Desktop.
Playing around with shell and its file descriptors
package main
import "os"
func main() {
my_file := os.NewFile(5, "doesn't matter!")
my_file.Write([]byte("hallo =)\n"))
}
use std::fs::File;
use std::io::Write;
use std::os::unix::io::FromRawFd;
fn main() {
let mut my_file: File;
unsafe {
my_file = File::from_raw_fd(5);
}
my_file.write("hallo, wie gehts?\n".as_bytes()).unwrap();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment