Skip to content

Commit acf7fb9

Browse files
committed
Add note about libc::exit's unsafety.
Fixes #19245.
1 parent b21a6da commit acf7fb9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/liblibc/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4157,6 +4157,27 @@ pub mod funcs {
41574157
pub fn malloc(size: size_t) -> *mut c_void;
41584158
pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
41594159
pub fn free(p: *mut c_void);
4160+
4161+
/// Exits the running program in a possibly dangerous manner.
4162+
///
4163+
/// # Unsafety
4164+
///
4165+
/// While this forces your program to exit, it does so in a way that has
4166+
/// consequences. This will skip all unwinding code, which means that anything
4167+
/// relying on unwinding for cleanup (such as flushing and closing a buffer to a
4168+
/// file) may act in an unexpected way.
4169+
///
4170+
/// # Examples
4171+
///
4172+
/// ```no_run
4173+
/// extern crate libc;
4174+
///
4175+
/// fn main() {
4176+
/// unsafe {
4177+
/// libc::exit(1);
4178+
/// }
4179+
/// }
4180+
/// ```
41604181
pub fn exit(status: c_int) -> !;
41614182
pub fn _exit(status: c_int) -> !;
41624183
pub fn atexit(cb: extern fn()) -> c_int;

0 commit comments

Comments
 (0)