From f8b18593198cf7ca1adfca19d846e66080b07942 Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Thu, 10 Oct 2019 12:45:34 -0700 Subject: Fix signalfd polling. The signalfd descriptors otherwise always show as available. This can lead programs to spin, assuming they are looking to see what signals are pending. Updates #139 PiperOrigin-RevId: 274017890 --- test/syscalls/linux/signalfd.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') diff --git a/test/syscalls/linux/signalfd.cc b/test/syscalls/linux/signalfd.cc index 54c598627..9379d5878 100644 --- a/test/syscalls/linux/signalfd.cc +++ b/test/syscalls/linux/signalfd.cc @@ -312,6 +312,23 @@ TEST(Signalfd, KillStillKills) { EXPECT_EXIT(tgkill(getpid(), gettid(), SIGKILL), KilledBySignal(SIGKILL), ""); } +TEST(Signalfd, Ppoll) { + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, SIGKILL); + FileDescriptor fd = + ASSERT_NO_ERRNO_AND_VALUE(NewSignalFD(&mask, SFD_CLOEXEC)); + + // Ensure that the given ppoll blocks. + struct pollfd pfd = {}; + pfd.fd = fd.get(); + pfd.events = POLLIN; + struct timespec timeout = {}; + timeout.tv_sec = 1; + EXPECT_THAT(RetryEINTR(ppoll)(&pfd, 1, &timeout, &mask), + SyscallSucceedsWithValue(0)); +} + } // namespace } // namespace testing -- cgit v1.2.3