From sef@kithrup.com  Mon Nov 10 14:50:27 1997
Received: from kithrup.com (kithrup.com [205.179.156.40])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id OAA05461
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 10 Nov 1997 14:48:32 -0800 (PST)
          (envelope-from sef@kithrup.com)
Received: (from sef@localhost)
	by kithrup.com (8.8.7/8.8.7) id OAA09389;
	Mon, 10 Nov 1997 14:47:48 -0800 (PST)
	(envelope-from sef)
Message-Id: <199711102247.OAA09389@kithrup.com>
Date: Mon, 10 Nov 1997 14:47:48 -0800 (PST)
From: Sean Eric Fagan <sef@kithrup.com>
Reply-To: sef@kithrup.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: problem with mail and more
X-Send-Pr-Version: 3.2

>Number:         4998
>Category:       bin
>Synopsis:       mail and more do not work well with being suspended
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    peter
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 10 15:00:00 PST 1997
>Closed-Date:    Tue Dec 29 21:50:16 PST 1998
>Last-Modified:  Tue Dec 29 22:01:16 PST 1998
>Originator:     Sean Eric Fagan
>Release:        FreeBSD 2.2.5-STABLE i386
>Organization:
>Environment:

>Description:

While reading a mail message long enough for the pager to be invoked, I
typed control-Z to do something else briefly at the --MORE-- prompt.  When I
fg'd the process, I was back at mail's "& " prompt, instead of being in the
pager.

>How-To-Repeat:

See description.

>Fix:

>Release-Note:
>Audit-Trail:

From: Sean Eric Fagan <sef@kithrup.com>
To: FreeBSD-gnats-submit@FreeBSD.ORG
Cc:  Subject: bin/4998
Date: Mon, 10 Nov 1997 18:08:11 -0800 (PST)

 Some further information:  mail is running immediately because
 more is core dumping, getting a SIGBUS.  gdb and the core file say it
 is in some function called from raw_mode(0) -- however, gdb can't print
 out the function name.

From: Sean Eric Fagan <sef@kithrup.com>
To: FreeBSD-gnats-submit@FreeBSD.ORG
Cc:  Subject: bin/4998
Date: Mon, 10 Nov 1997 18:20:15 -0800 (PST)

 One last update:  this is, I think, a kernel problem -- I did the same thing
 on my 2.2-GAMMA system, and it did not core dump.  So I took the
 (staticly-linked) mail I compiled up on my 2.2.5 system, and tried to
 reproduce it -- no go, it dropped me back into more when I typed 'fg'.
 Since the version of mail I had compiled up was staticly-linked, I am left
 to conclude that the problem is due to the kernel.

From: Sean Eric Fagan <sef@kithrup.com>
To: FreeBSD-gnats-submit@FreeBSD.ORG
Cc:  Subject: Re: bin/4998
Date: Tue, 11 Nov 1997 22:51:14 -0800 (PST)

 Another bit of fact:  the following change to more causes it to stop
 core dumping.
 
 This should *not* be the "solution" -- there is something wrong in the
 kernel, I think, that is causing TCSADRAIN to not work for this case.
 Unfortunately, I can't reproduce it in any way that would let me run it
 under gdb -- "cat foo | ./more" doesn't do it, even though that does set up
 a pipe.
 
 Index: screen.c
 ===================================================================
 RCS file: /usr/cvs/src/usr.bin/more/screen.c,v
 retrieving revision 1.5
 diff -u -r1.5 screen.c
 --- screen.c	1995/08/05 21:25:28	1.5
 +++ screen.c	1997/11/12 06:49:10
 @@ -191,7 +191,7 @@
  #if TERMIO
  	(void)ioctl(2, TCSETAW, &s);
  #else
 -	tcsetattr(2, TCSADRAIN, &s);
 +	tcsetattr(2, TCSANOW, &s);
  #endif
  #else
  	struct sgttyb s;

State-Changed-From-To: open->closed
State-Changed-By: sef
State-Changed-When: Sat Mar 28 23:01:28 1998
State-Changed-Why:
2.2.6 no longer demonstrates this behaviour.  I don't know why, anymore than
I know why it happened in the first case... but it's fixed now.  Yay.

State-Changed-From-To: closed->open
State-Changed-By: sef
State-Changed-When: Sun Mar 29 20:50:49 1998
State-Changed-Why:
I just tried again... and more still core dumps.  This is on a pty,
logged in via unencrypted kerberos login.  The shell is tcsh 6.07.02.

Responsible-Changed-From-To: freebsd-bugs->	peter 
Responsible-Changed-By: phk 
Responsible-Changed-When: Sun Apr 26 23:59:16 PDT 1998 
Responsible-Changed-Why:  
->peter 
State-Changed-From-To: open->closed 
State-Changed-By: hoek 
State-Changed-When: Tue Dec 29 21:50:16 PST 1998 
State-Changed-Why:  
I'm pretty sure I fixed this back in rev. 1.4 of more/os.c.  The coredump 
(s/I fixed/committed Oliver Fromme's fix/) was due to more(1) not 
handling the reception of two signals in short succession correctly. 
See bin/5721.  See also r.1.3 of signal.c which I think fixed a problem 
with mail(1) and more(1) that caused more(1) to SIGCONT back-to-life 
as a blank screen.  The reason you couldn't always reproduce this 
bug was that it is very dependent on the timing of the second signal. 
Presumable the proposed fix in this pr just allowed more(1) to go 
to sleep before the second signal arrived (no flush, hence faster, 
theoretically). 
>Unformatted:
