*BSD News Article 29763


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msuinfo!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!jussieu.fr!ensta!itesec!frmug.fr.net!fasterix.frmug.fr.net!pb
From: pb@fasterix.frmug.fr.net (Pierre Beyssac)
Subject: sio CLOCAL bug, FreeBSD 1.1 Beta
Keywords: sio FreeBSD 1.1 Beta COM_BIDIR CLOCAL
Sender: pb@fasterix.frmug.fr.net (Pierre Beyssac)
Organization: considered harmful
Date: Thu, 28 Apr 1994 00:58:56 GMT
Message-ID: <1994Apr28.005856.11562@fasterix.frmug.fr.net>
Summary: writes on the callout device hang if CLOCAL not set
Lines: 85

[ copy to comp.os.386bsd.bugs and freebsd-bugs@freefall.cdrom.com
  Please answer on the news or by email to me directly, because
  I don't get the freebsd-bugs list ]

I seem to have a problem with the 1.1 Beta sio driver and CLOCAL.
Sorry I did not post this earlier (I know the 1.1 release is
scheduled for very soon), but it was part of a larger program that
I wanted to trim down.

So here it is. When using the callout device, the open() succeeds
but if CLOCAL is not set, the first write() on the device blocks,
probably waiting for carrier. If CLOCAL is set (after the open),
the write does not block.

Here is the program source.
--------------------------------
#include <stdio.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>

struct termios term;

int main()
{
	int fd;

	if ((fd = open ("/dev/cua01", O_RDWR)) < 0) {
	    perror("open");
	    return -1;
	}
	printf("open done\n");

	ioctl (fd, TIOCGETA, &term);
	term.c_cflag &= ~CLOCAL; /* |= CLOCAL does not block on write */
	ioctl (fd, TIOCSETA, &term);

	printf("a\n");
	write(fd, "a", 1);
	printf("a\n");
	write(fd, "a", 1);

	return 0;
}
--------------------------------

Initial conditions : a getty is on /dev/ttyd1, and :

$ ls -l /dev/cua01
crw-rw-rw-    1 uucp      28, 129 Apr 28 02:35 /dev/cua01
$ stty -a -f /dev/cua01
speed 57600 baud; 0 rows; 0 columns;
lflags: -icanon -isig -iexten -echo -echoe -echok -echoke -echonl
	-echoctl -echoprt -altwerase -noflsh -tostop -mdmbuf -flusho
	-pendin -nokerninfo -extproc
iflags: -istrip -icrnl -inlcr -igncr -ixon ixoff -ixany -imaxbel -ignbrk
	-brkint -inpck -ignpar -parmrk
oflags: -opost onlcr -oxtabs
cflags: cread cs8 -parenb -parodd hupcl clocal -cstopb -crtscts -dsrflow
	-dtrflow
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
	eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
	quit = ^\; reprint = ^R; start = ^Q; status = <undef>; stop = ^S;
	susp = ^Z; werase = ^W;

After that, running the above source prints :

open done
a

and blocks.

Other details :
	The sio driver is of course compiled with option COM_BIDIR.
	The 1.1 Beta Taylor UUCP works nicely when calling out.
	The result is the same whatever the state of CLOCAL before the open()
	My UARTs are good old 16450s
	I run a kernel compiled from "stock" 1.1 Beta sources.
-- 
Pierre Beyssac                  FreeBSD@home: pb@fasterix.frmug.fr.net

FreeBSD, NetBSD, Linux 	-- Il y a moins bien, mais c'est plus cher.
You can also get less bang for more bucks. (translation F. Berjon)