[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[50 character or so descriptive subject here (for reference)]

From: Martin Flack
Subject: [50 character or so descriptive subject here (for reference)]
Date: Thu, 1 Mar 2001 00:10:41 -0500

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' 
-D_FILE_OFFSET_BITS=64  -I.  -I. -I./include -I./lib -I/usr/include -O2 
-march=i386 -mcpu=i686
uname output: Linux solvent 2.2.17-14 #1 Mon Feb 5 16:02:20 EST 2001 i686 
Machine Type: i386-redhat-linux-gnu

Bash Version: 2.04
Patch Level: 11
Release Status: release

        Red Hat Linux (and I suppose many other UNIX/Linux
configurations) disallows root login by telnet, and requires you to
login as a regular user and su to root. I frequently have telnet
connections open where I am running two levels of bash in this way. To
exit out when I'm finished working as root and finished altogether
with that host, I frequently hit CTRL+D CTRL+D in rapid succession,
since that will bring me out of both shells and close the
connection. Unfortunately, if I have emacs, mysql, ftp or some other
program(s) suspended via job control in my root session, I often blow
right past the "There are stoppped jobs" warning message due to my
reflex of hitting CTRL+D twice. I end up at the first shell prompt
thinking "oops".

        Simple: just login, su, start a program, suspend it, and hit

        I humbly submit a patch I wrote up for my local Red Hat Linux
7.0 system that will add a one second delay to the stopped jobs
message, and then flush the input buffer. A one second delay adds no
inconvenience, and I venture to guess that most users receive this
particular message when they're not expecting to, and pause to think
for a second anyway. The patch is below. This is my first
suggestion/contribution to an open source project so (kind) criticism
is welcome. :-) My only reservation is that termios.h might not be the
same header file outside of the Linux world, i.e. on other unixen, but
I have no idea so I leave that issue to wiser folk.
- Martin Flack, address@hidden

diff -u bash-2.04-orig/builtins/exit.def bash-2.04/builtins/exit.def
--- bash-2.04-orig/builtins/exit.def    Thu Aug  5 07:42:05 1999
+++ bash-2.04/builtins/exit.def Sat Feb 24 13:09:14 2001
@@ -32,6 +32,7 @@
 #include "../bashtypes.h"
 #include <stdio.h>
+#include <termios.h>
 #if defined (HAVE_UNISTD_H)
 #  include <unistd.h>
@@ -106,6 +107,23 @@
        if (jobs[i] && STOPPED (i))
            fprintf (stderr, "There are stopped jobs.\n");
+           /* Pause & flush input. Because of the popularity of
+              disallowing remote root login and encouraging the login
+              as a regular user followed by an su, it is easy to hit
+              CTRL+D CTRL+D to quickly end one's su'd+normal
+              sessions; except that when there are stopped jobs on
+              the first session, the second CTRL+D (usually hit in
+              rapid succession) blows past the message. Since we like
+              the ability to ignore the message when we choose, but
+              we don't like blowing past it, we should pause to make
+              sure the user sees the message and then kill the input
+              to get rid of any subsequent CTRL+D's he/she has hit.
+              MTF 2001/2/23 */
+           if (isatty(fileno(stdin))) {  /* don't mess with non-tty's */
+             sleep(1);  /* may need to be 2 for slower peeps :-) */
+             tcflush (fileno(stdin), TCIFLUSH);
+           }
            /* This is NOT superfluous because EOF can get here without
               going through the command parser.  Set both last and this

reply via email to

[Prev in Thread] Current Thread [Next in Thread]