From 9bab65a3eff1845a4c836632678fc6bc3f429376 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 2 Aug 2006 17:40:18 +0000 Subject: 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(). --- ChangeLog.csl | 10 ++++++++++ gdb/gdbserver/server.c | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ChangeLog.csl b/ChangeLog.csl index f5c6570aa61..7ea98706cf4 100644 --- a/ChangeLog.csl +++ b/ChangeLog.csl @@ -1,3 +1,13 @@ +2006-08-02 Richard Sandiford + + 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(). + 2006-08-01 Vladimir Prus gdb/ diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 51b87642a83..7880ad2fd70 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -43,6 +43,20 @@ jmp_buf toplevel; unsigned long signal_pid; +/* 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); +} + static int start_inferior (char *argv[], char *statusptr) { @@ -56,7 +70,10 @@ start_inferior (char *argv[], char *statusptr) 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); /* Wait till we are at 1st instruction in program, return signal number. */ return mywait (statusptr, 0); -- cgit v1.2.1