1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +00:00

Userspace: Deal with select() returning EINTR on a signal interruption

Add a trivial CSafeSyscall template that calls a callback until it stops
returning EINTR, and use it everywhere we use select() now.

Thanks to Andreas for the suggestion of using a template parameter for
the syscall function to invoke.
This commit is contained in:
Robin Burchell 2019-07-21 13:46:53 +02:00 committed by Andreas Kling
parent a1eff3daba
commit f2c0e55070
5 changed files with 33 additions and 8 deletions

View file

@ -1,5 +1,6 @@
#include <AK/PrintfImplementation.h>
#include <LibCore/CIODevice.h>
#include <LibCore/CSyscallUtils.h>
#include <errno.h>
#include <stdio.h>
#include <sys/select.h>
@ -71,7 +72,7 @@ bool CIODevice::can_read_from_fd() const
struct timeval timeout {
0, 0
};
int rc = select(m_fd + 1, &rfds, nullptr, nullptr, &timeout);
int rc = CSyscallUtils::safe_syscall(select, m_fd + 1, &rfds, nullptr, nullptr, &timeout);
if (rc < 0) {
// NOTE: We don't set m_error here.
perror("CIODevice::can_read: select");