Function linux_unsafe::write 
source · pub unsafe fn write(fd: int, buf: *const c_void, count: size_t) -> ssize_tExpand description
Write to a file descriptor.
Examples found in repository?
examples/getpid.rs (line 9)
1 2 3 4 5 6 7 8 9 10 11 12 13
fn main() {
    let pid = unsafe { linux_unsafe::getpid() };
    let msg = format!("{}\n", pid);
    let msg_raw = msg.as_bytes();
    let msg_ptr = msg_raw.as_ptr() as *const linux_unsafe::void;
    let msg_size = msg_raw.len() * core::mem::size_of::<u8>();
    let written = unsafe { linux_unsafe::write(1, msg_ptr, msg_size) };
    if written < 0 {
        panic!("failed to write");
    }
}