From 7ee161af8df2912142c0ff165b3532b7292b5e45 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 28 Nov 2022 15:01:12 -0800 Subject: [PATCH] Fix the flaky tty_ownership test on Mac The tty_ownership test was sometimes failing. In this test, `fish_test_helper` creates a child and transfers the tty to it, "abandoning" the tty. In some cases, the child was running before the parent; the child claims the tty. When the parent tries to transfer it to the child, it get SIGTTIN and stops. Fix this by ignoring SIGTTIN and SIGTTOU. This only affects macOS and BSDs. --- src/fish_test_helper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fish_test_helper.cpp b/src/fish_test_helper.cpp index 475c56ddc..06689eeca 100644 --- a/src/fish_test_helper.cpp +++ b/src/fish_test_helper.cpp @@ -13,6 +13,10 @@ #include // for std::begin/end static void abandon_tty() { + // The parent may get SIGSTOPed when it tries to call tcsetpgrp if the child has already done + // it. Prevent this by ignoring signals. + signal(SIGTTIN, SIG_IGN); + signal(SIGTTOU, SIG_IGN); pid_t pid = fork(); if (pid < 0) { perror("fork");