1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 20:47:45 +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

@ -8,6 +8,7 @@
#include <Kernel/Net/IPv4.h>
#include <LibCore/CConfigFile.h>
#include <LibCore/CFile.h>
#include <LibCore/CSyscallUtils.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
@ -108,7 +109,7 @@ int main(int argc, char** argv)
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(server_fd, &rfds);
rc = select(server_fd + 1, &rfds, nullptr, nullptr, nullptr);
rc = CSyscallUtils::safe_syscall(select, server_fd + 1, &rfds, nullptr, nullptr, nullptr);
if (rc < 1) {
perror("select");
return 1;