blob: 9a16901d112189a4393204d9f79940d896c85a3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#pragma once
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <AK/StdLibExtras.h>
namespace CSyscallUtils {
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));
if (errno == EINTR)
continue;
ASSERT_NOT_REACHED();
}
return sysret;
}
}
}
|