]> granicus.if.org Git - strace/blobdiff - tests/filter-unavailable.c
strace: terminate itself if interrupted by a signal
[strace] / tests / filter-unavailable.c
index 6f865e694a454ec5b088ca77ed5cf9beb615ea6e..d424a81748f8d060375329bf931c6af463c37ad2 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
 #include <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -25,7 +33,8 @@ process(void)
 
        (void) close(0);
        (void) close(1);
-       assert(pipe(fds) == 0 && fds[0] == 0 && fds[1] == 1);
+       if (pipe(fds))
+               perror_msg_and_fail("pipe");
 
        for (i = 0; i < T; ++i)
                assert(pthread_create(&t, NULL, thread, NULL) == 0);
@@ -43,10 +52,13 @@ main(void)
        pid_t p;
 
        for (i = 0; i < P; ++i) {
-               assert((p = fork()) >= 0);
+               p = fork();
+               if (p < 0)
+                       perror_msg_and_fail("fork");
                if (p == 0)
                        return process();
-               assert(waitpid(p, &s, 0) == p && WIFEXITED(s));
+               assert(waitpid(p, &s, 0) == p);
+               assert(WIFEXITED(s));
                if (WEXITSTATUS(s))
                        return WEXITSTATUS(s);
        }