Skip to content

Commit

Permalink
Move unique_thread_exit call to lang_start_internal so it is not in a…
Browse files Browse the repository at this point in the history
… generic function, and wrap it in `catch_unwind`
  • Loading branch information
zachs18 committed Jul 3, 2024
1 parent 47d0cbc commit 079f999
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions std/src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ fn lang_start_internal(
rtabort!("drop of the panic payload panicked");
});
panic::catch_unwind(cleanup).map_err(rt_abort)?;
// Guard against multple threads calling `libc::exit` concurrently.
// See the documentation for `unique_thread_exit` for more information.
panic::catch_unwind(|| crate::sys::common::exit_guard::unique_thread_exit())
.map_err(rt_abort)?;
ret_code
}

Expand All @@ -161,8 +165,5 @@ fn lang_start<T: crate::process::Termination + 'static>(
argv,
sigpipe,
);
// Guard against multple threads calling `libc::exit` concurrently.
// See the documentation for `unique_thread_exit` for more information.
crate::sys::common::exit_guard::unique_thread_exit();
v
}

0 comments on commit 079f999

Please sign in to comment.