aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2006-08-02 17:40:18 +0000
committerRichard Sandiford <rdsandiford@googlemail.com>2006-08-02 17:40:18 +0000
commit9bab65a3eff1845a4c836632678fc6bc3f429376 (patch)
tree662bce8548d6d45030b27a557e0fd438d39eacae
parent4f9782980e88d82bff9bfde4d0acd69dab37991d (diff)
downloadgdb-gdb-csl-20060226-branch.zip
gdb-gdb-csl-20060226-branch.tar.gz
gdb-gdb-csl-20060226-branch.tar.bz2
* 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().
-rw-r--r--ChangeLog.csl10
-rw-r--r--gdb/gdbserver/server.c19
2 files changed, 28 insertions, 1 deletions
diff --git a/ChangeLog.csl b/ChangeLog.csl
index f5c6570..7ea9870 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,3 +1,13 @@
+2006-08-02 Richard Sandiford <richard@codesourcery.com>
+
+ 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 <vladimir@codesourcery.com>
gdb/
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 51b8764..7880ad2 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);