about summary refs log tree commit diff
path: root/tests/ui/thread-local/spawn-hook-atexit.rs
blob: b084e0bb387852d9a2b1d135fe594aae03136cc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Regression test for https://github.com/rust-lang/rust/issues/138696
//@ only-unix
//@ needs-threads
//@ run-pass

#![feature(rustc_private)]

extern crate libc;

fn main() {
    std::thread::spawn(|| {
        unsafe { libc::atexit(spawn_in_atexit) };
    })
    .join()
    .unwrap();
}

extern "C" fn spawn_in_atexit() {
    std::thread::spawn(|| {
        println!("Thread spawned in atexit");
    })
    .join()
    .unwrap();
}