]> granicus.if.org Git - strace/commitdiff
signalfd4: fix flags decoding
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 3 Aug 2015 09:47:25 +0000 (09:47 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 3 Aug 2015 09:57:14 +0000 (09:57 +0000)
* configure.ac (AC_CHECK_FUNCS): Add eventfd.
(AC_CHECK_HEADERS): Add sys/signalfd.h.
* signalfd.c: Include <fcntl.h>.
[HAVE_SYS_SIGNALFD_H] Include <sys/signalfd.h>.
Include "xlat/sfd_flags.h".
(do_signalfd): Use sfd_flags for flags decoding.
* xlat/sfd_flags.in: New file.
* tests/signalfd.c: Likewise.
* tests/signalfd.expected: Likewise.
* tests/signalfd.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add signalfd.
(TESTS): Add signalfd.test.
(EXTRA_DIST): Add signalfd.expected.
* tests/.gitignore: Add signalfd.

configure.ac
signalfd.c
tests/.gitignore
tests/Makefile.am
tests/signalfd.c [new file with mode: 0644]
tests/signalfd.expected [new file with mode: 0644]
tests/signalfd.test [new file with mode: 0755]
xlat/sfd_flags.in [new file with mode: 0644]

index 8c7e8264246b7bac76293cba3a14a6d7d88f1e37..359402b99050001c193dd4149848a8f091bc3221 100644 (file)
@@ -242,6 +242,7 @@ AC_CHECK_FUNCS(m4_normalize([
        sendmsg
        sendmmsg
        sigaction
+       signalfd
        stpcpy
        strerror
        strsignal
@@ -272,6 +273,7 @@ AC_CHECK_HEADERS(m4_normalize([
        sys/fanotify.h
        sys/ioctl.h
        sys/reg.h
+       sys/signalfd.h
        sys/vfs.h
        sys/xattr.h
 ]))
index f574d1b1c5466d044d529a9866aa99bc32fff39d..4cfd6de5f059083041388ea3b19da72362f70fe3 100644 (file)
@@ -1,4 +1,10 @@
 #include "defs.h"
+#include <fcntl.h>
+#ifdef HAVE_SYS_SIGNALFD_H
+# include <sys/signalfd.h>
+#endif
+
+#include "xlat/sfd_flags.h"
 
 static int
 do_signalfd(struct tcb *tcp, int flags_arg)
@@ -10,7 +16,7 @@ do_signalfd(struct tcb *tcp, int flags_arg)
        tprintf(", %lu", tcp->u_arg[2]);
        if (flags_arg >= 0) {
                tprints(", ");
-               printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
+               printflags(sfd_flags, tcp->u_arg[flags_arg], "SFD_???");
        }
 
        return RVAL_DECODED | RVAL_FD;
index ee71e788c84c15b25d1fe31f69d7b811c1188e3a..6d8e3183f72f7c320ac3dc5f916b4fae81c390d3 100644 (file)
@@ -31,6 +31,7 @@ select
 set_ptracer_any
 sigaction
 sigaltstack
+signalfd
 sigreturn
 stack-fcall
 stat
index 180f473916aa97b3cb64a9569948a644ffdbd736..45b34ab59fdbbb495dbafe8c5e779e01cb93b126 100644 (file)
@@ -42,6 +42,7 @@ check_PROGRAMS = \
        set_ptracer_any \
        sigaction \
        sigaltstack \
+       signalfd \
        sigreturn \
        stack-fcall \
        stat \
@@ -92,6 +93,7 @@ TESTS = \
        select.test \
        sigaction.test \
        sigaltstack.test \
+       signalfd.test \
        sigreturn.test \
        stat.test \
        stat32-v.test \
@@ -162,6 +164,7 @@ EXTRA_DIST = init.sh run.sh match.awk \
             select.awk \
             sigaction.awk \
             sigaltstack.expected \
+            signalfd.expected \
             statfs.expected \
             sun_path.expected \
             uid.awk \
diff --git a/tests/signalfd.c b/tests/signalfd.c
new file mode 100644 (file)
index 0000000..9d4cc98
--- /dev/null
@@ -0,0 +1,26 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <fcntl.h>
+#include <signal.h>
+#include <unistd.h>
+#ifdef HAVE_SYS_SIGNALFD_H
+# include <sys/signalfd.h>
+#endif
+
+int
+main(void)
+{
+#if defined HAVE_SYS_SIGNALFD_H && defined HAVE_SIGNALFD
+       sigset_t mask;
+       sigemptyset(&mask);
+       sigaddset(&mask, SIGUSR2);
+       sigaddset(&mask, SIGCHLD);
+       (void) close(0);
+       return signalfd(-1, &mask, O_CLOEXEC | O_NONBLOCK) == 0 ?
+               0 : 77;
+#else
+        return 77;
+#endif
+}
diff --git a/tests/signalfd.expected b/tests/signalfd.expected
new file mode 100644 (file)
index 0000000..21937bc
--- /dev/null
@@ -0,0 +1 @@
+signalfd4\(-1, \[(USR2 CHLD|CHLD USR2)\], (4|8|16), SFD_CLOEXEC\|SFD_NONBLOCK\) += 0
diff --git a/tests/signalfd.test b/tests/signalfd.test
new file mode 100755 (executable)
index 0000000..dcbfe68
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check signalfd4 syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog
+run_strace -e signalfd4 $args
+match_grep
+
+exit 0
diff --git a/xlat/sfd_flags.in b/xlat/sfd_flags.in
new file mode 100644 (file)
index 0000000..badd55d
--- /dev/null
@@ -0,0 +1,2 @@
+SFD_CLOEXEC    O_CLOEXEC
+SFD_NONBLOCK   O_NONBLOCK