]> git.lizzy.rs Git - rust.git/commitdiff
Add note about libc::exit's unsafety.
authorSteve Klabnik <steve@steveklabnik.com>
Mon, 12 Jan 2015 18:13:01 +0000 (13:13 -0500)
committerSteve Klabnik <steve@steveklabnik.com>
Sat, 17 Jan 2015 15:49:49 +0000 (10:49 -0500)
Fixes #19245.

src/liblibc/lib.rs

index deab0cabfbe5195bfce29fbb75be076cdb0b4c55..7fb609b4c9450fd486beee123e67cb7a6f2922b0 100644 (file)
@@ -4168,6 +4168,27 @@ pub fn strtoul(s: *const c_char, endp: *mut *mut c_char,
                 pub fn malloc(size: size_t) -> *mut c_void;
                 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
                 pub fn free(p: *mut c_void);
+
+                /// Exits the running program in a possibly dangerous manner.
+                ///
+                /// # Unsafety
+                ///
+                /// While this forces your program to exit, it does so in a way that has
+                /// consequences. This will skip all unwinding code, which means that anything
+                /// relying on unwinding for cleanup (such as flushing and closing a buffer to a
+                /// file) may act in an unexpected way.
+                ///
+                /// # Examples
+                ///
+                /// ```no_run
+                /// extern crate libc;
+                ///
+                /// fn main() {
+                ///     unsafe {
+                ///         libc::exit(1);
+                ///     }
+                /// }
+                /// ```
                 pub fn exit(status: c_int) -> !;
                 pub fn _exit(status: c_int) -> !;
                 pub fn atexit(cb: extern fn()) -> c_int;