This change fixes a bug where fcntl(F_GETFD) would swallow error codes
from uk_fdtab_getflags and not return them up the callstack.
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
GitHub-Closes: #1602
case F_DUPFD:
return uk_sys_dup_min(fd, (int)arg, fdflags);
case F_GETFD:
- return (uk_fdtab_getflags(fd) & O_CLOEXEC) ? FD_CLOEXEC : 0;
+ fdflags = uk_fdtab_getflags(fd);
+ if (unlikely(fdflags < 0))
+ return fdflags;
+ return (fdflags & O_CLOEXEC) ? FD_CLOEXEC : 0;
case F_SETFD:
return uk_fdtab_setflags(fd,
((int)arg & FD_CLOEXEC) ? O_CLOEXEC : 0);