This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gdb not setting controlling terminal (+patch) (fwd)


Hi,

What happened to this bug report and patch? I don't know for sure
if it is a gdb or glibc bug.

Thanks.


H.J.
------
From svivano.pdmi.ras.ru!serg Mon Apr 12 17:29:23 1999
Return-Path: <serg@svivano.pdmi.ras.ru>
Received: from hilbert.pdmi.ras.ru by ocean.lucon.org with smtp
	(Linux Smail3.2.0.103 #1) id m10Wr4r-000ErMC; Mon, 12 Apr 1999 17:29:21 -0700 (PDT)
Received: from gauss.pdmi.ras.ru (gauss.pdmi.ras.ru [195.208.36.3])
	by hilbert.pdmi.ras.ru (8.8.8/8.8.8/Debian/GNU) with ESMTP id EAA30065;
	Tue, 13 Apr 1999 04:29:35 +0400
Received: from svivano.pdmi.ras.ru (uucp@localhost)
	by gauss.pdmi.ras.ru (8.8.8/8.8.8/Debian/GNU) with UUCP id EAA28830;
	Tue, 13 Apr 1999 04:30:04 +0400
Received: by svivano.pdmi.ras.ru (Smail-3.2 1996-Jul-4 #1) id m10Wr4p-000Ll6C
	for hjl@lucon.org; Tue, 13 Apr 1999 04:29:19 +0400 (MSD)
Message-Id: <m10Wr4p-000Ll6C@svivano.pdmi.ras.ru>
From: Sergei Ivanov <svivanov@pdmi.ras.ru>
Subject: gdb not setting controlling terminal (+patch)
To: bugs-gdb@gnu.org
Date: Tue, 13 Apr 1999 04:29:19 +0400 (MSD)
Cc: hjl@lucon.org
Organization: Steklov Institute of Mathematics at St.Petersburg
Reply-To: svivanov@pdmi.ras.ru
X-Mailer: ELM [version 2.4 PL25]

Hello

I'm resending my own report about a bug in gdb-4.17.0.11/Linux,
now for gdb-4.18 and with a partial fix.

The original report is included at the end of this message, and
everything in it remains valid except the version of gdb.
The system is i586-pc-linux-gnu, kernel 2.2.5, glibc 2.1.
gdb-4.18 was ./configure'd with --prefix=/usr --disable-nls.

The problem is with gdb's 'tty' command. The gdb manual reads:

    [...] It also resets the controlling terminal for the child
    process, for future `run' commands.  For example,

         tty /dev/ttyb

    directs that processes started with subsequent `run' commands default
    to do input and output on the terminal `/dev/ttyb' and have that as
    their controlling terminal.

However on this system 'tty' has no effect on the controlling terminal.
The controlling terminal of the child appears the same as that of gdb.
See the original report below for a resulting real-life problem
(a program under gdb tries to read from /dev/tty and fails with SIGTTIN).

In gdb-4.16 (at least on linux-libc5 systems), an effect of 'tty'
was to run a process with no controlling terminal at all.
And this is better for practical purposes.

The code doing this is still there in the source (file inflow.c,
function 'new_tty', a piece of code under '#ifdef TIOCNOTTY').
But it does not work for a silly reason - inflow.c does not manage
to include <sys/ioctl.h>!  So TIOCNOTTY is not defined there and
the code is not compiled in. Including <sys/ioctl.h> returns the
old behavior with no controlling terminal.

Here is the patch.

--- gdb-4.18/gdb/terminal.h.orig	Mon Apr 12 20:36:36 1999
+++ gdb-4.18/gdb/terminal.h	Mon Apr 12 20:56:29 1999
@@ -48,6 +48,7 @@
 
 #if defined(HAVE_TERMIOS)
 #include <termios.h>
+#include <sys/ioctl.h>
 #endif
 
 #if !defined(__GO32__) && !defined(_WIN32) && !defined (HAVE_TERMIOS)


The original report follows.

> Subject: gdb not setting controlling terminal
> To: hjl@lucon.org
> Date: Fri, 9 Apr 1999 21:31:31 +0400 (MSD)
> Organization: Steklov Institute of Mathematics at St.Petersburg
> Reply-To: svivanov@pdmi.ras.ru
> 
> Hello
> 
> With gdb-4.17.0.11 under linux-2.2.5 & glibc-2.1 (all compiled
> by egcs-1.1.X), I have the following gdb session on the console:
> 
> -----------
> ~$ gdb /usr/bin/less
> GNU gdb 4.17.0.11 with Linux support
> Copyright 1998 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "i586-pc-linux-gnu"...
> (no debugging symbols found)...
> (gdb) set args a.c
> (gdb) tty /dev/tty7
> (gdb) run
> Starting program: /usr/bin/less a.c
> (no debugging symbols found)...(no debugging symbols found)...
> Program received signal SIGTTIN, Stopped (tty input).
> 0x400fa354 in __read ()
> (gdb)
> ------------
> 
> This happens after 'less' displayed its first screen (on /dev/tty7).
> 
> 'ps' shows that that less runs _not_ on /dev/tty7 but on /dev/tty1
> where gdb was started.  Looks like 'tty' command in gdb redirects
> stdin/out/err but not the controlling terminal - contrary to the docs.
> 
> /dev/tty7 is a fresh virtual console owned by the appropriate user.
> It is readable and writeable. The above session runs fine on my
> backup system: linux-2.0.33, libc-5.4.44, gdb-4.16.
> 
> Regards
> Sergei
>