diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index 53c0490422..e1b905df0a 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -684,6 +684,7 @@ pub unsafe extern "C" fn sys_ioctl(fd: RawFd, cmd: i32, argp: *mut core::ffi::c_ #[hermit_macro::system(errno)] #[unsafe(no_mangle)] pub extern "C" fn sys_fcntl(fd: i32, cmd: i32, arg: i32) -> i32 { + const F_GETFD: i32 = 1; const F_SETFD: i32 = 2; const F_GETFL: i32 = 3; const F_SETFL: i32 = 4; @@ -691,6 +692,9 @@ pub extern "C" fn sys_fcntl(fd: i32, cmd: i32, arg: i32) -> i32 { if cmd == F_SETFD && arg == FD_CLOEXEC { 0 + } else if cmd == F_GETFD { + // Only the FD_CLOEXEC flag is defined, and it has no effect in hermit, so always return 0 + 0 } else if cmd == F_GETFL { let obj = get_object(fd); obj.map_or_else(