From nick@zephyr.specialix.com  Mon Mar  9 07:48:19 1998
Received: from zephyr.specialix.com (zephyr.specialix.com [192.65.145.58])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA01818
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 9 Mar 1998 07:48:16 -0800 (PST)
          (envelope-from nick@zephyr.specialix.com)
Received: (from nick@localhost)
	by zephyr.specialix.com (8.8.5/8.8.5) id HAA25446;
	Mon, 9 Mar 1998 07:48:14 -0800 (PST)
Message-Id: <199803091548.HAA25446@zephyr.specialix.com>
Date: Mon, 9 Mar 1998 07:48:14 -0800 (PST)
From: Nick Sayer <nick@specialix.com>
Reply-To: nick@specialix.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: Cannot set up clocal gettys
X-Send-Pr-Version: 3.2

>Number:         5959
>Category:       bin
>Synopsis:       Cannot set up clocal gettys
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    nsayer
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar  9 07:50:02 PST 1998
>Closed-Date:    Mon Jul 31 16:50:50 PDT 2000
>Last-Modified:  Mon Jul 31 16:52:09 PDT 2000
>Originator:     Nick Sayer
>Release:        FreeBSD 2.2.2-RELEASE i386
>Organization:
Just me
>Environment:

>Description:

There seems to be no documented way to set up gettys with clocal in effect.
Setting clocal in /dev/ttyid0 seems to be overridden when the getty actually
starts, and there is no flag I can find in gettytab that will set clocal.
Even setting the appropriate bits in c0, c1 and c2 doesn't seem to work.

>How-To-Repeat:

Set up a std.9600 getty on ttyd0, but don't kill -1 1 yet.
stty clocal < /dev/ttyid0
kill -1 1
stty -a </dev/ttyd0

The last stty will hang, because ttyd0 is waiting on a carrier
inappropriately.

>Fix:

As a workaround, you can fire up gettys on the cua devices, but that's
not really what they're for.

>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: FreeBSD-gnats-submit@FreeBSD.ORG, nick@specialix.com
Cc:  Subject: Re: bin/5959: Cannot set up clocal gettys
Date: Tue, 10 Mar 1998 17:52:11 +1100

 >There seems to be no documented way to set up gettys with clocal in effect.
 >Setting clocal in /dev/ttyid0 seems to be overridden when the getty actually
 >starts, and there is no flag I can find in gettytab that will set clocal.
 >Even setting the appropriate bits in c0, c1 and c2 doesn't seem to work.
 
 The bug in getty seems to be that you have to specify a complete set of
 flags (as sort of documented in the man page), AND all flags in the set
 must be nonzero.  The complete sets are {c0, i0, l0, o0}, {c1, i1, l1, o1}, 
 and {c2, i2, l2, o2}.  The '1' flags in local.9600 in gettytab don't work,
 because some of them are zero.  I think this can be worked around by
 setting an unused flag bit.
 
 You can lock clocal in /dev/ttyld0 after setting (or clearing) it in 
 dev/ttyid0.  /etc/rc.conf has an example.  This prevents buggy programs
 from changing it.  It also prevents non-buggy programs from changing it.
 
 >>How-To-Repeat:
 >
 >Set up a std.9600 getty on ttyd0, but don't kill -1 1 yet.
 >stty clocal < /dev/ttyid0
 >kill -1 1
 >stty -a </dev/ttyd0
 >
 >The last stty will hang, because ttyd0 is waiting on a carrier
 >inappropriately.
 
 This is working as intended.  The setting of the initial-state device
 only applies to first opens.  Opens of an already-open tty have no
 effect on the termios state.  Set ttyd0 as well as ttyid0 if you want
 the changes to take effect immediately, or set ttyid0 in /etc/rc.serial
 or /etc/rc.local if you always want the same settings.
 
 Bruce

From: Nick <nsayer@quack.kfu.com>
To: freebsd-gnats-submit@freebsd.org
Cc:  Subject: Re: bin/5959: Cannot set up clocal gettys
Date: Wed, 11 Mar 1998 16:42:41 +0000

 This patch adds the 'nc' flag to getty, which will make getty
 open non-blocking and set clocal.
 
 Many wet noodle whippings to getty for totally and willfully
 destroying the settings one sets up on the i device.
 
 --- init.c.orig Sat May 10 22:28:54 1997
 +++ init.c      Tue Mar 10 16:45:48 1998
 @@ -142,5 +142,6 @@
         { "np", 0 },                    /* no parity at all (8bit chars)
 */
         { "mb", 0 },                    /* do MDMBUF flow control */
         { "hw", 0 },                    /* do CTSRTS flow control */
 +       { "nc", 0 },                    /* set clocal */
         { 0 }
  };
 --- gettytab.h.orig     Sat May 10 22:28:53 1997
 +++ gettytab.h  Tue Mar 10 16:52:04 1998
 @@ -170,4 +170,5 @@
  #define        NP      gettyflags[21].value
  #define        MB      gettyflags[22].value
  #define HW     gettyflags[23].value
 +#define NC     gettyflags[24].value
 
 --- main.c.orig Sun Aug 17 16:44:34 1997
 +++ main.c      Tue Mar 10 16:57:58 1998
 @@ -266,8 +266,8 @@
                                 (void)tcsetattr(STDIN_FILENO, TCSANOW,
 &tmode);
                                 exit(1);
                         }
 -               } else { /* blocking open */
 -                       if (!opentty(ttyn, O_RDWR))
 +               } else { /* maybe blocking open */
 +                       if (!opentty(ttyn, O_RDWR|(NC?O_NONBLOCK:0)))
                                 exit(1);
                 }
             }
 @@ -289,6 +289,7 @@
         tmode.c_oflag = TTYDEF_OFLAG;
         tmode.c_lflag = TTYDEF_LFLAG;
         tmode.c_cflag = TTYDEF_CFLAG;
 +       tmode.c_cflag |= (NC?CLOCAL:0);
         omode = tmode;
 
 
 
Responsible-Changed-From-To: freebsd-bugs->nsayer 
Responsible-Changed-By: nrahlstr 
Responsible-Changed-When: Mon Jul 10 19:01:20 PDT 2000 
Responsible-Changed-Why:  
Originator is now a committer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=5959 
State-Changed-From-To: open->closed 
State-Changed-By: nsayer 
State-Changed-When: Mon Jul 31 16:50:50 PDT 2000 
State-Changed-Why:  
Committed to -current. On my list to MFC later. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=5959 
>Unformatted:
