Skip to content

Commit d55ca92

Browse files
authored
Merge pull request #2482 from hermit-os/fcntl-getfd
fix(fcntl): return 0 on F_GETFD
2 parents 30cb3f9 + 726c9b1 commit d55ca92

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/syscalls/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,13 +684,17 @@ pub unsafe extern "C" fn sys_ioctl(fd: RawFd, cmd: i32, argp: *mut core::ffi::c_
684684
#[hermit_macro::system(errno)]
685685
#[unsafe(no_mangle)]
686686
pub extern "C" fn sys_fcntl(fd: i32, cmd: i32, arg: i32) -> i32 {
687+
const F_GETFD: i32 = 1;
687688
const F_SETFD: i32 = 2;
688689
const F_GETFL: i32 = 3;
689690
const F_SETFL: i32 = 4;
690691
const FD_CLOEXEC: i32 = 1;
691692

692693
if cmd == F_SETFD && arg == FD_CLOEXEC {
693694
0
695+
} else if cmd == F_GETFD {
696+
// Only the FD_CLOEXEC flag is defined, and it has no effect in hermit, so always return 0
697+
0
694698
} else if cmd == F_GETFL {
695699
let obj = get_object(fd);
696700
obj.map_or_else(

0 commit comments

Comments
 (0)