2022-07-17 20:54:10 -05:00
|
|
|
//@ignore-target-windows: No libc on Windows
|
2020-04-26 16:24:48 -05:00
|
|
|
|
|
|
|
// Joining the main thread is undefined behavior.
|
|
|
|
|
|
|
|
use std::{ptr, thread};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let thread_id: libc::pthread_t = unsafe { libc::pthread_self() };
|
|
|
|
let handle = thread::spawn(move || {
|
|
|
|
unsafe {
|
2022-07-31 19:15:15 -05:00
|
|
|
assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread
|
2020-04-26 16:24:48 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
thread::yield_now();
|
|
|
|
handle.join().unwrap();
|
|
|
|
}
|