#pragma once #include #include #include #include #include namespace CSyscallUtils { template inline int safe_syscall(Syscall syscall, Args&&... args) { for (;;) { int sysret = syscall(forward(args)...); if (sysret == -1) { int saved_errno = errno; dbg() << "CSafeSyscall: " << sysret << " (" << saved_errno << ": " << strerror(saved_errno) << ")"; if (errno == EINTR) continue; ASSERT_NOT_REACHED(); } return sysret; } } }