On Haiku, I'm seeing this test failure (in a testdir of posix_openpt grantpt pt_chown ):
FAIL: test-posix_openpt ======================= ../../gltests/test-posix_openpt.c:58: assertion '0 <= slave' failed Abort FAIL test-posix_openpt (exit status: 149) This patch fixes it: 2024-08-30 Bruno Haible <br...@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(). diff --git a/tests/test-posix_openpt.c b/tests/test-posix_openpt.c index 95d69cd7ae..fdca5820d9 100644 --- a/tests/test-posix_openpt.c +++ b/tests/test-posix_openpt.c @@ -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);