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.
This commit is contained in:
ridiculousfish 2022-11-28 15:01:12 -08:00
parent b6ca8dca27
commit 7ee161af8d

View File

@ -13,6 +13,10 @@
#include <iterator> // 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");