commit e2a79cf900ad48826685edea49a88c8f72d2e75f from: Stefan Sperling via: Thomas Adam date: Wed Jul 26 19:15:43 2023 UTC prevent ncurses signal handlers from being installed while using mock-io Aborting tog regress with Ctrl-C would trigger a "tty" pledge violation via the built-in ncurses handler for SIGINT, installed by newterm(). Install tog's own signal handlers earlier to fix this. commit - d1c85b424404fbdc9500dcdf4ecf4b418bf5ec1f commit + e2a79cf900ad48826685edea49a88c8f72d2e75f blob - d40b3fadc427a43f99fe7a1e1b4790786b6b1253 blob + 5b0d0805104fc83a7d6cf6fbb127e9db3cedf4de --- tog/tog.c +++ tog/tog.c @@ -4434,17 +4434,6 @@ done: static void init_curses(void) { - /* - * Override default signal handlers before starting ncurses. - * This should prevent ncurses from installing its own - * broken cleanup() signal handler. - */ - signal(SIGWINCH, tog_sigwinch); - signal(SIGPIPE, tog_sigpipe); - signal(SIGCONT, tog_sigcont); - signal(SIGINT, tog_sigint); - signal(SIGTERM, tog_sigterm); - if (using_mock_io) /* In test mode we use a fake terminal */ return; @@ -10090,6 +10079,17 @@ main(int argc, char *argv[]) setlocale(LC_CTYPE, ""); /* + * Override default signal handlers before starting ncurses. + * This should prevent ncurses from installing its own + * broken cleanup() signal handler. + */ + signal(SIGWINCH, tog_sigwinch); + signal(SIGPIPE, tog_sigpipe); + signal(SIGCONT, tog_sigcont); + signal(SIGINT, tog_sigint); + signal(SIGTERM, tog_sigterm); + + /* * Test mode init must happen before pledge() because "tty" will * not allow TTY-related ioctls to occur via regular files. */