io/FileDescriptor: fold CreateSignalFD() into the SignalFD constructor
This commit is contained in:
parent
b5fbfe9aa6
commit
a79454f6a6
|
@ -236,21 +236,6 @@ FileDescriptor::CheckDuplicate(FileDescriptor new_fd) const noexcept
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
bool
|
||||
FileDescriptor::CreateSignalFD(const sigset_t *mask) noexcept
|
||||
{
|
||||
int new_fd = ::signalfd(fd, mask, SFD_NONBLOCK|SFD_CLOEXEC);
|
||||
if (new_fd < 0)
|
||||
return false;
|
||||
|
||||
fd = new_fd;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool
|
||||
FileDescriptor::Rewind() const noexcept
|
||||
{
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <csignal>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
@ -180,10 +176,6 @@ public:
|
|||
bool CheckDuplicate(FileDescriptor new_fd) const noexcept;
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
bool CreateSignalFD(const sigset_t *mask) noexcept;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Close the file descriptor. It should not be called on an
|
||||
* "undefined" object. After this call, IsDefined() is guaranteed
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue