Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Nov 1995 11:27:10 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        grog@lemis.de
Cc:        hackers@FreeBSD.org
Subject:   Re: What happens to terminal settings on last close?
Message-ID:  <199511071827.LAA17990@phaeton.artisoft.com>
In-Reply-To: <199511071326.OAA05257@allegro.lemis.de> from "Greg Lehey" at Nov 7, 95 02:26:21 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> I'm currently playing around with terminal I/O, and have noticed a
> discrepancy in an area in which there is no consensus anyway.  I set
> CLOCAL on a line, and then close it, whereupon it promptly reverts to
> -CLOCAL.  The result is that when I try to re-open it, it hangs
> waiting for a DTR* signal which, in this case, will never come.

This is correct behaviour.  Each tty has a default "template" setting
which is restored on close.

This is identical to Sun behaviour, though the template setting process
uses /etc/rc.serial instead of a flags line on the device and a kernel
rebuild.  So the way you get a template is different, but the template
mechanism is the same.

> This is different from the standard BSD behaviour, which leaves the
> terminal flags the way they are on the last close, but it's the same
> as System V behaviour.

The BSD behaviour is to template as well.  The default system configuration
for BSD systems, and SunOS systems in particular, is to have the CLOCAL
flags *unset*.

The process on SunOS is somewhat confused by the fact that SunOS allows
an stty on an open device.  This is not allowed on SVR4, which uses the
O_EXCL flag when opening the device in getty or uugetty.  There's
actually a subtle bug on SVR4 related to this, since the O_EXCL flag can
not be unset by a non-blocking open.  With the flag set, a fork will
fail to keep the tty open.

> Is it intentional or accidental?  What do you think it should do?

It's intentional, and it should do what it does: put the terminal in
a known state.

If you want a different known state, you should modify /etc/rc.serial
("man 4 sio").

Typically CLOCAL is used to wait for DCD.  If you aren't interested
in waiting for DCD on opens, then you should do something about the
defaults.


This really begs the question:

How did you open the device to unset CLOCAL in the first place, and
why can't you use the same type of open in the program that is hanging
waiting for DCD (not DTR).


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511071827.LAA17990>