forked from Imagelibrary/binutils-gdb
gdb/gdbserver/
* server.c (terminal_fd): New variable. (old_foreground_pgrp): Likewise. (restore_old_foreground_pgrp): New function. (start_inferior): Record the terminal file descriptor in terminal_fd and its original foreground group in old_foreground_pgrp. Register restore_old_foreground_pgrp with atexit().
This commit is contained in:
@@ -45,6 +45,22 @@ jmp_buf toplevel;
|
||||
|
||||
unsigned long signal_pid;
|
||||
|
||||
#ifdef SIGTTOU
|
||||
/* A file descriptor for the controlling terminal. */
|
||||
int terminal_fd;
|
||||
|
||||
/* TERMINAL_FD's original foreground group. */
|
||||
pid_t old_foreground_pgrp;
|
||||
|
||||
/* Hand back terminal ownership to the original foreground group. */
|
||||
|
||||
static void
|
||||
restore_old_foreground_pgrp (void)
|
||||
{
|
||||
tcsetpgrp (terminal_fd, old_foreground_pgrp);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
start_inferior (char *argv[], char *statusptr)
|
||||
{
|
||||
@@ -62,7 +78,10 @@ start_inferior (char *argv[], char *statusptr)
|
||||
#ifdef SIGTTOU
|
||||
signal (SIGTTOU, SIG_IGN);
|
||||
signal (SIGTTIN, SIG_IGN);
|
||||
tcsetpgrp (fileno (stderr), signal_pid);
|
||||
terminal_fd = fileno (stderr);
|
||||
old_foreground_pgrp = tcgetpgrp (terminal_fd);
|
||||
tcsetpgrp (terminal_fd, signal_pid);
|
||||
atexit (restore_old_foreground_pgrp);
|
||||
#endif
|
||||
|
||||
/* Wait till we are at 1st instruction in program, return signal number. */
|
||||
|
||||
Reference in New Issue
Block a user