diff options
author | Thiago Jung Bauermann <bauerman@br.ibm.com> | 2008-03-12 14:10:56 +0000 |
---|---|---|
committer | Thiago Jung Bauermann <bauerman@br.ibm.com> | 2008-03-12 14:10:56 +0000 |
commit | 83116857a35fc5125d098984fae29a549a2b29f3 (patch) | |
tree | 345c301a7e13d9bdb1cbd65fb38a0fbe0bf92e26 /gdb/inflow.c | |
parent | 2774f1a679efef2fc5f9f9a445f7c1e904a13225 (diff) | |
download | gdb-83116857a35fc5125d098984fae29a549a2b29f3.zip gdb-83116857a35fc5125d098984fae29a549a2b29f3.tar.gz gdb-83116857a35fc5125d098984fae29a549a2b29f3.tar.bz2 |
* configure.ac (AC_CHECK_FUNCS): Add check for setsid.
* config.in, configure: Regenerate.
* fork-child.c (fork_inferior): Call create_tty_session.
* inflow.c (new_tty): Set controlling terminal with TIOCSCTTY.
(create_tty_session): New function.
* terminal.h: Declare create_tty_session.
Diffstat (limited to 'gdb/inflow.c')
-rw-r--r-- | gdb/inflow.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gdb/inflow.c b/gdb/inflow.c index f7bf7d1..d003a98 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -557,6 +557,16 @@ new_tty (void) close (2); dup (tty); } + +#ifdef TIOCSCTTY + /* Make tty our new controlling terminal. */ + if (ioctl (tty, TIOCSCTTY, 0) == -1) + /* Mention GDB in warning because it will appear in the inferior's + terminal instead of GDB's. */ + warning ("GDB: Failed to set controlling terminal: %s", + safe_strerror (errno)); +#endif + if (tty > 2) close (tty); #endif /* !go32 && !win32 */ @@ -683,6 +693,33 @@ clear_sigio_trap (void) #endif /* No SIGIO. */ +/* Create a new session if the inferior will run in a different tty. + A session is UNIX's way of grouping processes that share a controlling + terminal, so a new one is needed if the inferior terminal will be + different from GDB's. + + Returns the session id of the new session, 0 if no session was created + or -1 if an error occurred. */ +pid_t +create_tty_session (void) +{ +#ifdef HAVE_SETSID + pid_t ret; + + if (!job_control || inferior_thisrun_terminal == 0) + return 0; + + ret = setsid (); + if (ret == -1) + warning ("Failed to create new terminal session: setsid: %s", + safe_strerror (errno)); + + return ret; +#else + return 0; +#endif /* HAVE_SETSID */ +} + /* This is here because this is where we figure out whether we (probably) have job control. Just using job_control only does part of it because setpgid or setpgrp might not exist on a system without job control. |