diff options
author | Daniel Jacobowitz <drow@false.org> | 2002-08-29 18:50:25 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2002-08-29 18:50:25 +0000 |
commit | a9fa9f7daf3fdb5a1cc0149156ac8d497893cf0f (patch) | |
tree | a7aca92dbeec50d8e44abc5bc83432371681279b /gdb/gdbserver/server.c | |
parent | e551c2572e97cf7ab0a431f5a1f25207d9a4d179 (diff) | |
download | gdb-a9fa9f7daf3fdb5a1cc0149156ac8d497893cf0f.zip gdb-a9fa9f7daf3fdb5a1cc0149156ac8d497893cf0f.tar.gz gdb-a9fa9f7daf3fdb5a1cc0149156ac8d497893cf0f.tar.bz2 |
* 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.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index b674ed0..d0963ba 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; |