mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
exit: explain our expectations for the exit handlers registered in a Rust program
This commit is contained in:
parent
717aec0f8e
commit
21dd88f963
@ -2296,6 +2296,15 @@ impl Child {
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// In its current implementation, this function will execute exit handlers registered with `atexit`
|
||||
/// as well as other platform-specific exit handlers (e.g. `fini` sections of ELF shared objects).
|
||||
/// This means that Rust requires that all exit handlers are safe to execute at any time. In
|
||||
/// particular, if an exit handler cleans up some state that might be concurrently accessed by other
|
||||
/// threads, it is required that the exit handler performs suitable synchronization with those
|
||||
/// threads. (The alternative to this requirement would be to not run exit handlers at all, which is
|
||||
/// considered undesirable. Note that returning from `main` also calls `exit`, so making `exit` an
|
||||
/// unsafe operation is not an option.)
|
||||
///
|
||||
/// ## Platform-specific behavior
|
||||
///
|
||||
/// **Unix**: On Unix-like platforms, it is unlikely that all 32 bits of `exit`
|
||||
|
Loading…
Reference in New Issue
Block a user