From: Theodore Ts'o <tytso@athena.mit.edu> Subject: Re: slightly problem with new kernel, very slight Date: 13 Feb 1993 20:26:46 -0500
From: marcf@nexus.yorku.ca (Marc G Fournier)
Date: 13 Feb 93 06:11:34 GMT
Now, if I go into kermit to try and dial out, and I
presume that uucico will get the exact same thing, I get the
error message:
Sorry, can't open connection: /dev/ttycua9: Device or resource busy
The way things works are as follows.... the kernel takes care of locking
between the /dev/ttySXX and /dev/cuaXX devices. If some process has the
/dev/ttysXX device open, then an attempt to open the /dev/cuaXX device
will result in the "Device or resource busy" error.
Similarily, if a process has the /dev/cuaXX device open, then another
process attempting to open the /dev/ttysXX device will block until
*both* the /dev/cuaXX device is closed _and_ carrier detect is enabled.
This represents a change in how the /dev/ttysXX device worked before;
and is required by the POSIX specification. According to POSIX, opening
a serial line will block until the carrier detect is high; unless the
O_NONBLOCK flag is given to open, or if the termios CLOCAL flag is on.
Unfortunately, not all programs are written so that they will work
correctly given the POSIX spec; fortunately, most of these programs are
ones like kermit or uucico, which should be using the callout device,
/devcuaXX, annyway.
So, any programs that call out, such as kermit or uucico, should use
/dev/cuaXX, and getty should be configured to use /dev/ttySXX. This
way, they will automatically share the modem line without needing to
play any games with non-standard lock files.
Are there any catches? Well, three. First of all, also in 0.99pl5,
Linus changed the default state of CLOCAL to be enabled, to avoid
problems which niave users had reported when connecting devices such as
mice and terminals which did not support the carrier detect line. So in
your /etc/rc.local file, you need to the following for each line that
you want to use as a dialin device:
stty -clocal < /dev/cuaXX
The second catch is that some getty programs open /dev/ttySXX with the
O_NONBLOCK flag, which defeats the purpose of sharing the /dev/cuaXX and
/dev/ttysXX lines. A notable example of such a program is gettyps; it
can be made to work reliabily with 0.99pl5 by simply remocing the
O_NONBLOCK flag when it opens the seria line. On tsx-11.mit.edu, in
/pub/linux/ALPHA/serial/gettys.diff, there is a slightly more refined
set of patches adds a new option, '-n' which means *NO* O_NONBLOCK. I
am currently using the dialin/dialout device on ttys7 with these patches
and the following line in /etc/inittab:
c7:6:respawn:/bin/getty -n ttys7 19200
With these patches and the above line in /etc/inittab, the dialin and
dialout devices share my modem quite nicely.
The third catch is that some getty programs use the vhangup() call,
which has a bug in it causing DTR to drop briefly, and this makes the
modem hang up. A work-around for this problem is to either program your
modem so that it hangs up after a delay of 1/2 to 1 second after DTR
drops, or temporarily commenting out the vhangup() call in your getty.
I will be working on a patch to vhangup(), so these workarounds will
only be needed temporarily.
I hope this answers people's questions...... These answers should
probably get added to the SERIAL FAQ one of these days...
- Ted