Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Jun 1997 15:02:22 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        mcgovern@spoon.beta.com
Cc:        hackers@FreeBSD.ORG, questions@FreeBSD.ORG
Subject:   Re: Need help with O_NONBLOCK and pppd in FreeBSD....
Message-ID:  <199706022202.PAA15463@phaeton.artisoft.com>
In-Reply-To: <199706022051.QAA00272@bmcgover-pc.cisco.com> from "Brian McGovern" at Jun 2, 97 04:51:26 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> Which seems to tell me to set O_NONBLOCK, reguardless of whether we want to
> use modem control lines or not. Once in a non-blocking state, pppd is free
> to spin completely out of control. This is the last invokation I've found that
> effects the O_NONBLOCK attribute.
> 
> Now, in my opinion, this seems backwards. Wouldn't I potentially want to turn
> O_NONBLOCK  _ON_ first, in order to dial out, then turn it _OFF_ 
> unconditionally? Perhaps I'm missing something, but it seems strange. Please,
> set me straight....

O_NDELAY, the open flag, has two meanings:

1)	Do not wait for DCD before completing the open on a modem
	control device.

2)	Refuse all calls which would block with EWOULDBLOCK.

It used to be you could not turn non-blocking I/O off once it was on.

There are other issues of DCD when dialing out.


Basically, we are being POSIX'ed to death, and we are implementing
in other than the way SVR4 does because we are gratuitously incompatible
and we want to make things hard for the people doing the ABI code.

The corrrect sequence is:

a)	set 1 second alarm

b)	do blocking open

	i)	if open succeeds instead of alarming out, close
		the fd.  Not a warning on the console that the port
		is either non-modem control, or the modem cable is
		bad (DCD jumpered high) or the modem is incorrectly
		configured (DCD does not follow remote carrier).

	NB: This procesure unsets O_EXCL in the tty struct as set by
	uugetty and other software abominations before God.

c)	do non-blocking open.  This will succeed because non-blocking
	open always succeeds.  Because of step (b), you are assured
	that you will not get an EWOULDBLOCK/EPERM from an exclusivity
	conflict.

d)	do blocking open on second fd.  This will succeed because there
	is an existing open, so the DCD status is not checked.

e)	close the fd obtained in (c); it is useless.

f)	Proceed with operation using fd obtained in (d).  On DCD loss,
	you must close this fs and go to step (a).


This procedure will work correctly on all UNIX systems.


					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?199706022202.PAA15463>