--- src/timeout.c.old 2013-10-31 19:44:01.719755435 +0000 +++ src/timeout.c 2013-11-01 12:01:06.074839679 +0000 @@ -370,6 +370,7 @@ double timeout; char signame[SIG2STR_MAX]; int c; + struct sigaction sa, sa_ttin, sa_ttou; initialize_main (&argc, &argv); set_program_name (argv[0]); @@ -429,9 +430,16 @@ /* Setup handlers before fork() so that we handle any signals caused by child, without races. */ install_signal_handlers (term_signal); - signal (SIGTTIN, SIG_IGN); /* Don't stop if background child needs tty. */ - signal (SIGTTOU, SIG_IGN); /* Don't stop if background child needs tty. */ - signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */ + + /* Don't stop if background child needs tty. */ + sigemptyset (&sa.sa_mask); + sa.sa_handler = SIG_IGN; + sa.sa_flags = SA_RESTART; + sigaction (SIGTTIN, &sa, &sa_ttin); + sigaction (SIGTTOU, &sa, &sa_ttou); + + /* Don't inherit CHLD handling from parent. */ + signal (SIGCHLD, SIG_DFL); monitored_pid = fork (); if (monitored_pid == -1) @@ -443,9 +451,9 @@ { /* child */ int exit_status; - /* exec doesn't reset SIG_IGN -> SIG_DFL. */ - signal (SIGTTIN, SIG_DFL); - signal (SIGTTOU, SIG_DFL); + /* Restore old SIGTTIN/SIGTTOU handlers (RHBZ#1025269). */ + sigaction (SIGTTIN, &sa_ttin, NULL); + sigaction (SIGTTOU, &sa_ttou, NULL); execvp (argv[0], argv); /* FIXME: should we use "sh -c" ... here? */