[comp.unix.wizards] O_NDELAY flag on open system call on 4.2BSD

davem@sdcrdcf.UUCP (David Melman) (11/26/86)

I want to be able to check for carrier on a tty port without blocking.
I thought I would use the O_NDELAY flag in an open call, but I found
that the open still hangs, e.g 

>open (ttyline, O_WRONLY|O_NDELAY, 0);

Specifically, the tty port is a DEC DMZ.  
We are running 4.2bsd with Chris Torek's DMZ driver.

I'm doing this in order to determine whether a LaserJet printer is connect
or not.  It is shared between a our Vax and a micro.
How can I do this?

David Melman
UNISYS 

UUCP: {hplabs,cbosgd,ihnp4}!sdcrdcf!davem

chris@mimsy.UUCP (11/27/86)

In article <3472@sdcrdcf.UUCP>, davem@sdcrdcf.UUCP (David Melman) writes:
>I want to be able to check for carrier on a tty port without blocking.
>I thought I would use the O_NDELAY flag in an open call, but I found
>that the open still hangs, e.g 
>
>>open (ttyline, O_WRONLY|O_NDELAY, 0);
>
>Specifically, the tty port is a DEC DMZ.  

The 4.2 and 4.3 kernels do not check O_NDELAY before waiting for
carrier.  It is easy to add to a kernel, but (I think) the wrong
approach.

>We are running 4.2bsd with Chris Torek's DMZ driver.

Well, it is not `my' DMZ driver; I just edited it a bit.  But if
you have my version, you should have a `dmzoopen()' and a `dmzoclose()'
in it as well.  Configure these in (if you have not done so already)
in /sys/vax/conf.c, and then

	# mknod /dev/dialNN c <maj> <min>

where <maj> is the major device number that gets dmzoopen, and <min>
is the minor device number of the appropriate tty.  Opening the dial
line will succeed if and only if there is no one actively using the 
tty line.  If the tty line is in use (by, e.g., getty) the open will
fail with EBUSY.  The tty line opens will wait for carrier as usual;
dial line opens never wait for carrier.

(Exception: root can always open the dial line.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris@mimsy.umd.edu