aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2006-08-08 16:03:29 +0000
committerRichard Sandiford <rdsandiford@googlemail.com>2006-08-08 16:03:29 +0000
commit290fadea96dc9b5f6b3b657a16633ce3f6f48edd (patch)
treeb9db18c7e9731803e63a38ff84f2135162fdb7c1
parent3d00d119d389c59cf9223d0b74d1d0bce0d18511 (diff)
downloadgdb-290fadea96dc9b5f6b3b657a16633ce3f6f48edd.zip
gdb-290fadea96dc9b5f6b3b657a16633ce3f6f48edd.tar.gz
gdb-290fadea96dc9b5f6b3b657a16633ce3f6f48edd.tar.bz2
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().
-rw-r--r--gdb/gdbserver/ChangeLog9
-rw-r--r--gdb/gdbserver/server.c21
2 files changed, 29 insertions, 1 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 220c19b..a5a735a 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,12 @@
+2006-08-08 Richard Sandiford <richard@codesourcery.com>
+
+ * 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-07-26 Daniel Jacobowitz <dan@codesourcery.com>
* server.c (handle_query): Correct qPart to qXfer.
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 5fbe0f7..c30a61a 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -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. */