]> git.lizzy.rs Git - rust.git/blob - tests/run-pass/concurrency/libc_prctl_thread_name.rs
b8ba27b3a89545115fbb66032fcbb8562a282c95
[rust.git] / tests / run-pass / concurrency / libc_prctl_thread_name.rs
1 // ignore-windows: No libc on Windows
2 // ignore-macos: No prctl on MacOS
3
4 #![feature(rustc_private)]
5
6 extern crate libc;
7
8 use std::ffi::CString;
9
10 fn main() {
11     unsafe {
12         let thread_name = CString::new("hello").expect("CString::new failed");
13         assert_eq!(libc::prctl(libc::PR_SET_NAME, thread_name.as_ptr() as libc::c_long, 0 as libc::c_long, 0 as libc::c_long, 0 as libc::c_long), 0);
14         let mut buf = [0; 6];
15         assert_eq!(libc::prctl(libc::PR_GET_NAME, buf.as_mut_ptr() as libc::c_long, 0 as libc::c_long, 0 as libc::c_long, 0 as libc::c_long), 0);
16         assert_eq!(thread_name.as_bytes_with_nul(), buf);
17     }
18 }