Skip to content

Commit 868669f

Browse files
committed
Add note about libc::exit's unsafety.
Fixes #19245.
1 parent 89c4e37 commit 868669f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/liblibc/lib.rs

+21
Original file line numberDiff line numberDiff line change
@@ -4168,6 +4168,27 @@ pub mod funcs {
41684168
pub fn malloc(size: size_t) -> *mut c_void;
41694169
pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
41704170
pub fn free(p: *mut c_void);
4171+
4172+
/// Exits the running program in a possibly dangerous manner.
4173+
///
4174+
/// # Unsafety
4175+
///
4176+
/// While this forces your program to exit, it does so in a way that has
4177+
/// consequences. This will skip all unwinding code, which means that anything
4178+
/// relying on unwinding for cleanup (such as flushing and closing a buffer to a
4179+
/// file) may act in an unexpected way.
4180+
///
4181+
/// # Examples
4182+
///
4183+
/// ```no_run
4184+
/// extern crate libc;
4185+
///
4186+
/// fn main() {
4187+
/// unsafe {
4188+
/// libc::exit(1);
4189+
/// }
4190+
/// }
4191+
/// ```
41714192
pub fn exit(status: c_int) -> !;
41724193
pub fn _exit(status: c_int) -> !;
41734194
pub fn atexit(cb: extern fn()) -> c_int;

0 commit comments

Comments
 (0)