diff --git a/repos/libports/src/lib/libc/vfs_plugin.cc b/repos/libports/src/lib/libc/vfs_plugin.cc index cd6217982..a404b0b9a 100644 --- a/repos/libports/src/lib/libc/vfs_plugin.cc +++ b/repos/libports/src/lib/libc/vfs_plugin.cc @@ -818,7 +818,7 @@ int Libc::Vfs_plugin::fcntl(Libc::File_descriptor *fd, int cmd, long arg) break; } - PERR("fcntl(): command %d not supported", cmd); + PERR("fcntl(): command %d not supported - vfs", cmd); errno = EINVAL; return -1; } diff --git a/repos/libports/src/lib/libc_lock_pipe/plugin.cc b/repos/libports/src/lib/libc_lock_pipe/plugin.cc index 93bbe351e..9942684cd 100644 --- a/repos/libports/src/lib/libc_lock_pipe/plugin.cc +++ b/repos/libports/src/lib/libc_lock_pipe/plugin.cc @@ -232,12 +232,25 @@ namespace { int Plugin::fcntl(Libc::File_descriptor *pipefdo, int cmd, long arg) { switch (cmd) { - case F_GETFL: - if (is_write_end(pipefdo)) - return O_WRONLY; - else - return O_RDONLY; - default: PERR("fcntl(): command %d not supported", cmd); return -1; + case F_GETFL: + if (is_write_end(pipefdo)) + return O_WRONLY; + else + return O_RDONLY; + case F_SETFD: + { + const long supported_flags = FD_CLOEXEC; + /* if unsupported flags are used, fall through with error */ + if (!(arg & ~supported_flags)) { + /* close fd if exec is called - no exec support -> ignore */ + if (arg & FD_CLOEXEC) + return 0; + } + } + default: + PERR("fcntl(): command %d arg %ld not supported - pipe", + cmd, arg); + return -1; } } @@ -287,6 +300,7 @@ namespace { FD_ZERO(readfds); in_writefds = *writefds; FD_ZERO(writefds); + FD_ZERO(exceptfds); for (int libc_fd = 0; libc_fd < nfds; libc_fd++) { fdo = Libc::file_descriptor_allocator()->find_by_libc_fd(libc_fd); diff --git a/repos/libports/src/lib/libc_terminal/plugin.cc b/repos/libports/src/lib/libc_terminal/plugin.cc index e9466bab3..f91308270 100644 --- a/repos/libports/src/lib/libc_terminal/plugin.cc +++ b/repos/libports/src/lib/libc_terminal/plugin.cc @@ -297,8 +297,21 @@ namespace { int fcntl(Libc::File_descriptor *fd, int cmd, long arg) { switch (cmd) { - case F_GETFL: return context(fd)->status_flags(); - default: PERR("fcntl(): command %d not supported", cmd); return -1; + case F_GETFL: return context(fd)->status_flags(); + case F_SETFD: + { + const long supported_flags = FD_CLOEXEC; + /* if unsupported flags are used, fall through with error */ + if (!(arg & ~supported_flags)) { + /* close fd if exec is called - no exec support -> ignore */ + if (arg & FD_CLOEXEC) + return 0; + } + } + default: + PERR("fcntl(): command %d args %ld not supported - terminal", + cmd, arg); + return -1; } }