diff options
Diffstat (limited to 'tests/signalfd4.c')
-rw-r--r-- | tests/signalfd4.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/tests/signalfd4.c b/tests/signalfd4.c index e45e9425c..97e7977a2 100644 --- a/tests/signalfd4.c +++ b/tests/signalfd4.c @@ -20,20 +20,47 @@ # include <sys/signalfd.h> # include "kernel_fcntl.h" +#ifndef SKIP_IF_PROC_IS_UNAVAILABLE +# define SKIP_IF_PROC_IS_UNAVAILABLE +#endif + int main(void) { - const char *const sigs = SIGUSR2 < SIGCHLD ? "USR2 CHLD" : "CHLD USR2"; + SKIP_IF_PROC_IS_UNAVAILABLE; + + const char *const sigs1 = "USR2"; + const char *const sigs2 = SIGUSR2 < SIGCHLD ? "USR2 CHLD" : "CHLD USR2"; const unsigned int size = get_sigset_size(); sigset_t mask; sigemptyset(&mask); sigaddset(&mask, SIGUSR2); + + int fd = signalfd(-1, &mask, SFD_CLOEXEC | SFD_NONBLOCK); + +#ifdef PRINT_SIGNALFD + if (fd == -1) + perror_msg_and_skip("signalfd"); +#endif + + printf("signalfd4(-1, [%s], %u, SFD_CLOEXEC|SFD_NONBLOCK) = %s", + sigs1, size, sprintrc(fd)); +#ifdef PRINT_SIGNALFD + printf("<signalfd:[%s]>\n", sigs1); +#else + putchar('\n'); +#endif + sigaddset(&mask, SIGCHLD); + fd = signalfd(fd, &mask, 0); - int fd = signalfd(-1, &mask, O_CLOEXEC | O_NONBLOCK); - printf("signalfd4(-1, [%s], %u, SFD_CLOEXEC|SFD_NONBLOCK) = %s\n", - sigs, size, sprintrc(fd)); +#ifdef PRINT_SIGNALFD + printf("signalfd4(%d<signalfd:[%s]>, [%s], %u, 0) = %s<signalfd:[%s]>\n", + fd, sigs1, sigs2, size, sprintrc(fd), sigs2); +#else + printf("signalfd4(%d, [%s], %u, 0) = %s\n", fd, sigs2, size, sprintrc(fd)); +#endif puts("+++ exited with 0 +++"); return 0; |