1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37:45 +00:00

LibCore: Improve logging of errors in safe_syscall() somewhat

This commit is contained in:
Andreas Kling 2019-12-01 16:47:28 +01:00
parent cde0a1eeb5
commit 2ece61fa1f

View file

@ -1,18 +1,21 @@
#pragma once
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <AK/LogStream.h>
#include <AK/StdLibExtras.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
namespace CSyscallUtils {
template <typename Syscall, class... Args>
inline int safe_syscall(Syscall syscall, Args&& ... args) {
template<typename Syscall, class... Args>
inline int safe_syscall(Syscall syscall, Args&&... args)
{
for (;;) {
int sysret = syscall(forward<Args>(args)...);
if (sysret == -1) {
dbgprintf("CSafeSyscall: %d (%d: %s)\n", sysret, errno, strerror(errno));
int saved_errno = errno;
dbg() << "CSafeSyscall: " << sysret << " (" << saved_errno << ": " << strerror(saved_errno) << ")";
if (errno == EINTR)
continue;
ASSERT_NOT_REACHED();
@ -22,4 +25,3 @@ inline int safe_syscall(Syscall syscall, Args&& ... args) {
}
}