1
1
use crate :: backend;
2
2
3
- /// `EXIT_SUCCESS` for use with [`exit`].
4
- ///
5
- /// [`exit`]: std::process::exit
3
+ /// `EXIT_SUCCESS` for use with [`exit`] or [`std::process::exit`].
6
4
///
7
5
/// # References
8
6
/// - [POSIX]
@@ -12,9 +10,7 @@ use crate::backend;
12
10
/// [Linux]: https://man7.org/linux/man-pages/man3/exit.3.html
13
11
pub const EXIT_SUCCESS : i32 = backend:: c:: EXIT_SUCCESS ;
14
12
15
- /// `EXIT_FAILURE` for use with [`exit`].
16
- ///
17
- /// [`exit`]: std::process::exit
13
+ /// `EXIT_FAILURE` for use with [`exit`] or [`std::process::exit`].
18
14
///
19
15
/// # References
20
16
/// - [POSIX]
@@ -34,3 +30,30 @@ pub const EXIT_FAILURE: i32 = backend::c::EXIT_FAILURE;
34
30
/// [`Signal::Abort`]: crate::process::Signal::Abort
35
31
#[ cfg( not( any( target_os = "espidf" , target_os = "wasi" ) ) ) ]
36
32
pub const EXIT_SIGNALED_SIGABRT : i32 = backend:: c:: EXIT_SIGNALED_SIGABRT ;
33
+
34
+ /// Immediately exits the process. Exiting via this function does not unwind the
35
+ /// stack and does not call any further user code. This behavior is similar to
36
+ /// the POSIX/C `_Exit` and `_exit` functions.
37
+ ///
38
+ /// Notably, this function does:
39
+ /// - *Not* flush any buffers, such as Rust or C standard output or files.
40
+ /// - *Not* call any destructors, neither in the form of stack unwinding, nor
41
+ /// any global destructors.
42
+ /// - *Not* call functions registered with [`atexit`] or [`at_quick_exit`]
43
+ ///
44
+ /// In general, most code should call [`std::process::exit`] instead, if it is
45
+ /// available.
46
+ ///
47
+ /// # References
48
+ /// - [POSIX]
49
+ /// - [Linux]
50
+ ///
51
+ /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html
52
+ /// [Linux]: https://www.man7.org/linux/man-pages/man2/exit.2.html
53
+ /// [`atexit`]: https://www.man7.org/linux/man-pages/man3/atexit.3.html
54
+ /// [`at_quick_exit`]: https://en.cppreference.com/w/c/program/at_quick_exit
55
+ #[ doc( alias = "_exit" ) ]
56
+ #[ inline]
57
+ pub fn exit ( status : i32 ) -> ! {
58
+ backend:: process:: syscalls:: _exit ( status) ;
59
+ }
0 commit comments