io/FileDescriptor: fold CreateSignalFD() into the SignalFD constructor

This commit is contained in:
Max Kellermann
2023-03-09 18:00:23 +01:00
parent b5fbfe9aa6
commit a79454f6a6
3 changed files with 8 additions and 24 deletions

View File

@@ -11,8 +11,15 @@
void
SignalFD::Create(const sigset_t &mask)
{
if (!fd.CreateSignalFD(&mask))
int new_fd = ::signalfd(fd.Get(), &mask, SFD_NONBLOCK|SFD_CLOEXEC);
if (new_fd < 0)
throw MakeErrno("signalfd() failed");
if (!fd.IsDefined()) {
fd = UniqueFileDescriptor{new_fd};
}
assert(new_fd == fd.Get());
}
int