From: Dmitry V. Levin Date: Fri, 10 Jun 2016 14:20:25 +0000 (+0000) Subject: tests/attach-p-cmd-p.c: cleanup X-Git-Tag: v4.13~152 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87baaec12e6ac5aae0b5ea09087b6c07e6f1710f;p=strace tests/attach-p-cmd-p.c: cleanup * attach-p-cmd-p.c (handler): Move code ... (main): ... here. Unblock SIGALRM only. Use alarm() instead of setitimer(). Replace endless loop with a pause() call. Check that chdir() returns ENOENT. --- diff --git a/tests/attach-p-cmd-p.c b/tests/attach-p-cmd-p.c index 528d35a9..a059ce53 100644 --- a/tests/attach-p-cmd-p.c +++ b/tests/attach-p-cmd-p.c @@ -28,17 +28,14 @@ */ #include "tests.h" -#include +#include #include #include -#include -#include #include static void handler(int signo) { - _exit(!chdir("attach-p-cmd.test -p")); } int @@ -50,16 +47,17 @@ main(int ac, char **av) if (ac > 2) error_msg_and_fail("extra operand"); - const sigset_t set = {}; const struct sigaction act = { .sa_handler = handler }; - const struct itimerval itv = { .it_value.tv_sec = atoi(av[1]) }; + if (sigaction(SIGALRM, &act, NULL)) + perror_msg_and_skip("sigaction"); - assert(sigaction(SIGALRM, &act, NULL) == 0); - assert(sigprocmask(SIG_SETMASK, &set, NULL) == 0); - if (setitimer(ITIMER_REAL, &itv, NULL)) - perror_msg_and_skip("setitimer"); + sigset_t mask = {}; + sigaddset(&mask, SIGALRM); + if (sigprocmask(SIG_UNBLOCK, &mask, NULL)) + perror_msg_and_skip("sigprocmask"); - for (;;); + alarm(atoi(av[1])); + pause(); - return 0; + return !(chdir("attach-p-cmd.test -p") && ENOENT == errno); }