File tree Expand file tree Collapse file tree 3 files changed +39
-6
lines changed Expand file tree Collapse file tree 3 files changed +39
-6
lines changed Original file line number Diff line number Diff line change @@ -742,3 +742,14 @@ pub(crate) fn getgroups(buf: &mut [Gid]) -> io::Result<usize> {
742742
743743 unsafe { ret_usize ( c:: getgroups ( len, buf. as_mut_ptr ( ) . cast ( ) ) as isize ) }
744744}
745+
746+ #[ inline]
747+ pub ( crate ) fn _exit ( status : i32 ) -> ! {
748+ unsafe {
749+ libc:: _exit ( status) ;
750+ }
751+ #[ allow( unreachable_code) ]
752+ {
753+ unreachable ! ( "_exit failed to exit the process" )
754+ }
755+ }
Original file line number Diff line number Diff line change @@ -620,3 +620,14 @@ pub(crate) fn getgroups(buf: &mut [Gid]) -> io::Result<usize> {
620620 ) )
621621 }
622622}
623+
624+ #[ inline]
625+ pub ( crate ) fn _exit ( status : i32 ) -> ! {
626+ unsafe {
627+ syscall_noreturn ! ( __NR_exit_group, c_int( status) ) ;
628+ } ;
629+ #[ allow( unreachable_code) ]
630+ {
631+ unreachable ! ( "_exit failed to exit the process" )
632+ }
633+ }
Original file line number Diff line number Diff line change 11use crate :: backend;
22
3- /// `EXIT_SUCCESS` for use with [`exit`].
4- ///
5- /// [`exit`]: std::process::exit
3+ /// `EXIT_SUCCESS` for use with [`exit`] or [`std::process::exit`].
64///
75/// # References
86/// - [POSIX]
@@ -12,9 +10,7 @@ use crate::backend;
1210/// [Linux]: https://man7.org/linux/man-pages/man3/exit.3.html
1311pub const EXIT_SUCCESS : i32 = backend:: c:: EXIT_SUCCESS ;
1412
15- /// `EXIT_FAILURE` for use with [`exit`].
16- ///
17- /// [`exit`]: std::process::exit
13+ /// `EXIT_FAILURE` for use with [`exit`] or [`std::process::exit`].
1814///
1915/// # References
2016/// - [POSIX]
@@ -34,3 +30,18 @@ pub const EXIT_FAILURE: i32 = backend::c::EXIT_FAILURE;
3430/// [`Signal::Abort`]: crate::process::Signal::Abort
3531#[ cfg( not( any( target_os = "espidf" , target_os = "wasi" ) ) ) ]
3632pub 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+ /// # References
39+ /// - [POSIX]
40+ /// - [Linux]
41+ ///
42+ /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html
43+ /// [Linux]: https://www.man7.org/linux/man-pages/man2/exit.2.html
44+ #[ inline]
45+ pub fn exit ( status : i32 ) -> ! {
46+ backend:: process:: syscalls:: _exit ( status) ;
47+ }
You can’t perform that action at this time.
0 commit comments