On 12/18/14 12:14 PM, Jiri Kukacka wrote:
>> OK, this is the problem part. This looks like a bug in Solaris.
>> There's
>> no indication that the kernel sent SIGHUP before changing the behavior
>> of
>> read and write upon disconnect.
>>
>> Can you see whether or not the first bash in the chain gets a SIGHUP
>> here?
>> (Though I can't see why or how sending a SIGHUP to any process other
>> than
>> the tty's current foreground process group is useful.)
>
> Well, I can see that SIGHUP got to first bash just a few lines later (and
> that varies with every test, first this, then the other), and then it was
> passed through the chain to current foreground process.
> I can have a look at tty in Solaris, but since other shells don't have this
> problem, I think that it would be great to have bash aware of such things as
> well.
Here's a patch that inhibits bash from returning partial lines when read(2)
returns EOF. It works whether READLINE_CALLBACKS is defined or not (since
there are different code paths based on whether or not it is).
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.3-patched/lib/readline/readline.c 2014-10-01 13:08:28.000000000 -0400
--- lib/readline/readline.c 2014-12-20 22:37:28.000000000 -0500
***************
*** 580,592 ****
}
! /* EOF typed to a non-blank line is a <NL>. If we want to change this,
! to force any existing line to be ignored when read(2) reads EOF,
! for example, this is the place to change. */
if (c == EOF && rl_end)
! c = NEWLINE;
/* The character _rl_eof_char typed to blank line, and not as the
! previous character is interpreted as EOF. */
! if (((c == _rl_eof_char && lastc != c) || c == EOF) && !rl_end)
{
#if defined (READLINE_CALLBACKS)
--- 587,620 ----
}
! /* EOF typed to a non-blank line is ^D the first time, EOF the second
! time in a row. This won't return any partial line read from the tty.
! If we want to change this, to force any existing line to be returned
! when read(2) reads EOF, for example, this is the place to change. */
if (c == EOF && rl_end)
! {
! if (RL_SIG_RECEIVED ())
! {
! RL_CHECK_SIGNALS ();
! if (rl_signal_event_hook)
! (*rl_signal_event_hook) (); /* XXX */
! }
!
! /* XXX - reading two consecutive EOFs returns EOF */
! if (RL_ISSTATE (RL_STATE_TERMPREPPED))
! {
! if (lastc == _rl_eof_char || lastc == EOF)
! rl_end = 0;
! else
! c = _rl_eof_char;
! }
! else
! c = NEWLINE;
! }
/* The character _rl_eof_char typed to blank line, and not as the
! previous character is interpreted as EOF. This doesn't work when
! READLINE_CALLBACKS is defined, so hitting a series of ^Ds will
! erase all the chars on the line and then return EOF. */
! if (((c == _rl_eof_char && lastc != c) || c == EOF) && rl_end == 0)
{
#if defined (READLINE_CALLBACKS)