@@ -3280,10 +3280,15 @@ fi
# signalfd probe
signalfd="no"
cat > $TMPC << EOF
-#include <unistd.h>
-#include <sys/syscall.h>
+#include <sys/signalfd.h>
#include <signal.h>
-int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
+int main(void)
+{
+ sigset_t s;
+
+ sigfillset(&s);
+ return signalfd(-1, &s, SFD_CLOEXEC);
+}
EOF
if compile_prog "" "" ; then
@@ -17,7 +17,7 @@
#include "qemu/compatfd.h"
#include "qemu/thread.h"
-#include <sys/syscall.h>
+#include <sys/signalfd.h>
struct sigfd_compat_info
{
@@ -99,9 +99,8 @@ int qemu_signalfd(const sigset_t *mask)
#if defined(CONFIG_SIGNALFD)
int ret;
- ret = syscall(SYS_signalfd, -1, mask, _NSIG / 8);
+ ret = signalfd(-1, mask, SFD_CLOEXEC);
if (ret != -1) {
- qemu_set_cloexec(ret);
return ret;
}
#endif
qemu_signalfd() provides the (effects of the) Linux signalfd() syscall on platforms that lack it. However, the check for the availability of signalfd() in configure, and its use in qemu_signalfd() when it *is* available, are seriously outdated (they date back to 2010-2011). To wit, the SYS_signalfd-based check in configure can actually fail on at least modern aarch64 Linux systems that *do* have signalfd(). (SYS_signalfd is deprecated and has been replaced by SYS_signalfd4 (note the "4"). The signalfd() libc function selects the appropriate system call.) We should consider signalfd() accessible as a first class libc function on platforms that support it. Modernize the related parts in configure and "util/compatfd.c" (so that we end up with something similar to eventfd()'s detection). Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- configure | 11 ++++++++--- util/compatfd.c | 5 ++--- 2 files changed, 10 insertions(+), 6 deletions(-)