diff --git a/Libraries/LibCore/System.cpp b/Libraries/LibCore/System.cpp index 4d6d65f4dc6..586a3a9070c 100644 --- a/Libraries/LibCore/System.cpp +++ b/Libraries/LibCore/System.cpp @@ -1010,4 +1010,11 @@ bool is_socket(int fd) return !result.is_error() && S_ISSOCK(result.value().st_mode); } +ErrorOr sleep_ms(u32 milliseconds) +{ + if (usleep(1000 * milliseconds) != 0) + return Error::from_syscall("usleep"sv, -errno); + return {}; +} + } diff --git a/Libraries/LibCore/System.h b/Libraries/LibCore/System.h index 06b11979994..ee195dc3806 100644 --- a/Libraries/LibCore/System.h +++ b/Libraries/LibCore/System.h @@ -181,5 +181,6 @@ ErrorOr set_resource_limits(int resource, rlim_t limit); int getpid(); bool is_socket(int fd); +ErrorOr sleep_ms(u32 milliseconds); } diff --git a/Libraries/LibCore/SystemWindows.cpp b/Libraries/LibCore/SystemWindows.cpp index 519c236bfcf..21f857e6c52 100644 --- a/Libraries/LibCore/SystemWindows.cpp +++ b/Libraries/LibCore/SystemWindows.cpp @@ -225,4 +225,10 @@ bool is_socket(int handle) return GetFileType(to_handle(handle)) == FILE_TYPE_PIPE; } +ErrorOr sleep_ms(u32 milliseconds) +{ + Sleep(milliseconds); + return {}; +} + }