]> Savannah Git Hosting - gnulib.git/commitdiff
posix_openpt tests: Fix test failure on Haiku.
authorBruno Haible <bruno@clisp.org>
Fri, 30 Aug 2024 21:48:44 +0000 (23:48 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 17 Sep 2024 11:09:13 +0000 (13:09 +0200)
* tests/test-posix_openpt.c (main): On Haiku, create a child process and
call setsid().

ChangeLog
tests/test-posix_openpt.c

index 85fae34ea2c8c8a0489e6d434c1932f6805618c7..83b15ee13e7f461b286245e51d4211d56d8f3061 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-08-30  Bruno Haible  <bruno@clisp.org>
+
+       posix_openpt tests: Fix test failure on Haiku.
+       * tests/test-posix_openpt.c (main): On Haiku, create a child process and
+       call setsid().
+
 2024-08-30  Bruno Haible  <bruno@clisp.org>
 
        sigsegv: Clarify license of the *.m4 files.
index 95d69cd7ae513647427e7fd9e66fea9859fb5cfe..fdca5820d95d174a2d0e22ecbf3a20fb471d3386 100644 (file)
@@ -54,6 +54,29 @@ main (void)
   ASSERT (name);
   ASSERT (grantpt (master) == 0);
   ASSERT (unlockpt (master) == 0);
+
+#if defined __HAIKU__
+  /* On Haiku, the open() call below succeeds only if
+       - done in a child process, and
+       - if that child process has done a setsid() call.
+     So, do that.  */
+  pid_t child_pid = fork ();
+  ASSERT (child_pid >= 0);
+  if (child_pid > 0)
+    {
+      /* We are in the parent.  Wait for the child to terminate.  */
+      int child_status;
+      ASSERT (waitpid (child_pid, &child_status, 0) != -1);
+      ASSERT (WIFEXITED (child_status));
+      int child_exit_status = WEXITSTATUS (child_status);
+      ASSERT (child_exit_status == 0);
+
+      return test_exit_status;
+    }
+  /* We are in the child.  */
+  ASSERT (setsid () >= 0);
+#endif
+
   slave = open (name, O_RDWR);
   ASSERT (0 <= slave);