Subject: COM_SW_CLOCAL and "cu" (was: COM_SW_SOFTCAR handling)
To: Chris G. Demetriou <>
From: Duncan McEwan <duncan@Comp.VUW.AC.NZ>
List: current-users
Date: 07/25/1994 21:12:12
A week or so ago I asked about the need for both the COM_SW_SOFTCAR and
COM_SW_CLOCAL flags in the com driver, since they both seemed to accomplish the
same thing, particularly if what I considered to be a bug relating to the
COM_SW_SOFTCAR handling of DTR got fixed.

cgd replied:

> 'clocal' and 'softcar' are supposed to be used by different things.
> the former is when you want the line to "default" to seeming like
> carrier is detected, but want it to be able to be disabled.
> ...
> softcar is supposed to be used _only_ for hardwired terminals
> that don't provide DCD themselves.

I still think it's a bug that setting COM_SW_SOFTCAR via ttyflags leaves DTR on
all the time.  But if it's only used with hardwired terminals, I guess it
doesn't hurt.  It does mean that the correct response to something like ...

|> From:  Tim Chase <>
|> Subject:  The pppd blocking thing... softcar works.
|> Date:  Wed, 13 Jul 1994 11:29:34 -0500 (CDT)
|> ...
|> setting the softcar flag from /etc/ttys works just fine and is obviously the
|> proper solution to using pppd, tip or whatever for outgoing calls (if the
|> program in question doesn't use a nonblocking open).

... should be:

  "Use softcar when your tty line is not connected to a modem.  Otherwise
   use the "local" flag, which sets the CLOCAL bit if you want DTR to work
   correctly with your modem."

Unfortunately people who use "cu" rather than "tip" won't like this advice
since it doesn't work :-)

If you do a "cu -l /dev/tty01" where tty01 has had the COM_SW_CLOCAL bit set by
ttyflags, the open succeeds.  But when you try to type anything you get

	cu: write: input/output error

I've looked at the "cu" code, but it's a little hard to figure out what is
going on.  I think the sequence of opening the tty ends up with fsserial_open
in libunix/serial.c being called with the fwait parameter set to false.  This
causes "cu" to open the line in non-blocking mode (not strictly needed here
since CLOCAL is on), but it then turns CLOCAL off a little further on in the

Presumably the error occurs because the bsd tty driver won't let you write to a
device that has no carrier if neither SOFTCAR or CLOCAL are switched on.  This
seems to be sensible behaviour.  I'm not sure how "cu" works on other systems.
Do they only care about the presence or absence of carrier at the time the port
is opened?