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 | 8da5a53dcaf1316a1d984f3daeaa74619c964798 (patch) | |
tree | 7f7f74055a9e2cf47fd80de3aab6713fae5f0560 /gdb/inflow.c | |
parent | 4ab486b7cb8d4ee1b4a005fb3d81acd1b9b412b4 (diff) | |
download | gdb-8da5a53dcaf1316a1d984f3daeaa74619c964798.tar.gz |
* 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 f7bf7d12e30..d003a98dcd1 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. |