From 77c9e53ee2e823cf45bf2ef7afb396f1edbec37e Mon Sep 17 00:00:00 2001
From: 4lDO2 <4lDO2@protonmail.com>
Date: Thu, 4 Jul 2024 15:09:33 +0200
Subject: [PATCH] Fix sigchld test.

---
 tests/sigchld.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tests/sigchld.c b/tests/sigchld.c
index 5e8a9ce2..455f9981 100644
--- a/tests/sigchld.c
+++ b/tests/sigchld.c
@@ -26,13 +26,18 @@ void handler(int sig) {
 }
 
 int main(void) {
-    int child = fork();
-    ERROR_IF(fork, child, == -1);
-
     int fds[2];
     int status = pipe(fds);
     ERROR_IF(pipe, status, == -1);
 
+    int child = fork();
+    ERROR_IF(fork, child, == -1);
+
+    sigset_t set;
+    sigemptyset(&set);
+    status = sigprocmask(SIG_SETMASK, &set, NULL);
+    ERROR_IF(sigprocmask, status, == -1);
+
     struct sigaction sa;
     sigemptyset(&sa.sa_mask);
     sa.sa_flags = 0;
@@ -75,6 +80,9 @@ int main(void) {
         assert(WSTOPSIG(waitpid_stat) == SIGSTOP);
         puts("Correct, sending SIGCONT...");
 
+        status = write(fds[1], "C", 1);
+        ERROR_IF(write, status, == -1);
+
         status = kill(child, SIGCONT);
         ERROR_IF(kill, status, == -1);
 
@@ -91,7 +99,7 @@ int main(void) {
         puts("Child exited.");
 
         puts("Writing to (broken) pipe.");
-        status = write(fds[1], "C", 1);
+        status = write(fds[1], "B", 1);
         ERROR_IF(write, status, != -1);
         assert(errno == EPIPE);
 
-- 
GitLab