summaryrefslogtreecommitdiff
path: root/gdb/gdbserver/server.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2002-08-29 18:50:25 +0000
committerDaniel Jacobowitz <dan@debian.org>2002-08-29 18:50:25 +0000
commit21520042a372e406d8e45c1d4b114e66162c90c9 (patch)
tree1ac181bdf2b46b65aabce85eb20fe6012258ab5c /gdb/gdbserver/server.c
parent941b4c1f69e3557190c5cbc0abdb4b26774bcec5 (diff)
downloadgdb-21520042a372e406d8e45c1d4b114e66162c90c9.tar.gz
* linux-low.c (linux_create_inferior): Call setpgid. Return
the new PID. (unstopped_p, linux_signal_pid): Remove. (linux_target_ops): Remove linux_signal_pid. * remote-utils.c (putpkt, input_interrupt): Use signal_pid global instead of target method. * target.h (struct target_ops): Remove signal_pid. Update comment for create_inferior. * server.c (signal_pid): New variable. (create_inferior): Set signal_pid. Block SIGTTOU and SIGTTIN in gdbserver. Set the child to be the foreground process group. (attach_inferior): Set signal_pid.
Diffstat (limited to 'gdb/gdbserver/server.c')
-rw-r--r--gdb/gdbserver/server.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index b674ed0070f..d0963ba9de9 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -21,6 +21,10 @@
#include "server.h"
+#include <unistd.h>
+#include <signal.h>
+#include <sys/wait.h>
+
int cont_thread;
int general_thread;
int step_thread;
@@ -31,14 +35,27 @@ int server_waiting;
jmp_buf toplevel;
+/* The PID of the originally created or attached inferior. Used to
+ send signals to the process when GDB sends us an asynchronous interrupt
+ (user hitting Control-C in the client), and to wait for the child to exit
+ when no longer debugging it. */
+
+int signal_pid;
+
static unsigned char
start_inferior (char *argv[], char *statusptr)
{
- /* FIXME Check error? Or turn to void. */
- create_inferior (argv[0], argv);
+ signal (SIGTTOU, SIG_DFL);
+ signal (SIGTTIN, SIG_DFL);
+
+ signal_pid = create_inferior (argv[0], argv);
fprintf (stderr, "Process %s created; pid = %d\n", argv[0],
- all_threads.head->id);
+ signal_pid);
+
+ signal (SIGTTOU, SIG_IGN);
+ signal (SIGTTIN, SIG_IGN);
+ tcsetpgrp (fileno (stderr), signal_pid);
/* Wait till we are at 1st instruction in program, return signal number. */
return mywait (statusptr, 0);
@@ -49,9 +66,15 @@ attach_inferior (int pid, char *statusptr, unsigned char *sigptr)
{
/* myattach should return -1 if attaching is unsupported,
0 if it succeeded, and call error() otherwise. */
+
if (myattach (pid) != 0)
return -1;
+ /* FIXME - It may be that we should get the SIGNAL_PID from the
+ attach function, so that it can be the main thread instead of
+ whichever we were told to attach to. */
+ signal_pid = pid;
+
*sigptr = mywait (statusptr, 0);
return 0;