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:
parent
cde0a1eeb5
commit
2ece61fa1f
1 changed files with 9 additions and 7 deletions
|
@ -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) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue