mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
LibCore: Improve logging of errors in safe_syscall() somewhat
This commit is contained in:
parent
cde0a1eeb5
commit
2ece61fa1f
1 changed files with 9 additions and 7 deletions
|
@ -1,18 +1,21 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <errno.h>
|
#include <AK/LogStream.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace CSyscallUtils {
|
namespace CSyscallUtils {
|
||||||
|
|
||||||
template <typename Syscall, class... Args>
|
template<typename Syscall, class... Args>
|
||||||
inline int safe_syscall(Syscall syscall, Args&& ... args) {
|
inline int safe_syscall(Syscall syscall, Args&&... args)
|
||||||
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int sysret = syscall(forward<Args>(args)...);
|
int sysret = syscall(forward<Args>(args)...);
|
||||||
if (sysret == -1) {
|
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)
|
if (errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
|
@ -22,4 +25,3 @@ inline int safe_syscall(Syscall syscall, Args&& ... args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue