From 5f71bf0cc7de17d0aa2703aabf4e0cad5f000ae8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 28 Mar 2021 17:50:08 +0200 Subject: [PATCH] Kernel+LibC: Implement sys$ioctl() FIONBIO This is another (older) way of making a file descriptor non-blocking. --- Kernel/Syscalls/ioctl.cpp | 5 +++++ Userland/Libraries/LibC/sys/ioctl_numbers.h | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Kernel/Syscalls/ioctl.cpp b/Kernel/Syscalls/ioctl.cpp index 2d06bffa34..acff91dfd1 100644 --- a/Kernel/Syscalls/ioctl.cpp +++ b/Kernel/Syscalls/ioctl.cpp @@ -26,6 +26,7 @@ #include #include +#include namespace Kernel { @@ -34,6 +35,10 @@ KResultOr Process::sys$ioctl(int fd, unsigned request, FlatPtr arg) auto description = file_description(fd); if (!description) return EBADF; + if (request == FIONBIO && arg != 0) { + description->set_blocking(false); + return KSuccess; + } return description->file().ioctl(*description, request, arg); } diff --git a/Userland/Libraries/LibC/sys/ioctl_numbers.h b/Userland/Libraries/LibC/sys/ioctl_numbers.h index df31bebaf9..345f2d43de 100644 --- a/Userland/Libraries/LibC/sys/ioctl_numbers.h +++ b/Userland/Libraries/LibC/sys/ioctl_numbers.h @@ -68,7 +68,8 @@ enum IOCtlNumber { SIOCSIFNETMASK, SIOCADDRT, SIOCDELRT, - FIBMAP + FIBMAP, + FIONBIO, }; #define TIOCGPGRP TIOCGPGRP @@ -94,3 +95,4 @@ enum IOCtlNumber { #define SIOCADDRT SIOCADDRT #define SIOCDELRT SIOCDELRT #define FIBMAP FIBMAP +#define FIONBIO FIONBIO