unistd/mod.rs: implement posix_close

This is a valid implementation according to POSIX,
as long as we do not support `POSIX_CLOSE_RESTART`.
This commit is contained in:
Connor-GH
2026-01-23 15:52:54 -06:00
parent ee648a4e57
commit e5997cf828
+7 -3
View File
@@ -812,10 +812,14 @@ pub unsafe extern "C" fn pipe2(fildes: *mut c_int, flags: c_int) -> c_int {
.or_minus_one_errno()
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/close.html>.
// #[unsafe(no_mangle)]
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_close.html>.
#[unsafe(no_mangle)]
pub extern "C" fn posix_close(fildes: c_int, flag: c_int) -> c_int {
unimplemented!();
// Since we do not define `POSIX_CLOSE_RESTART`, this function is
// equivalent to `close`. In the future when we move file descriptors
// to userspace, it would only make sense to define `POSIX_CLOSE_RESTART`
// if `close` is not atomic.
close(fildes)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/read.html>.