Getty and PPP

Harald Becker ralda at gmx.de
Fri Oct 21 19:49:18 UTC 2011


 Hallo Denys!

> One related gray area is whether we should use open(O_NONBLOCK)
> or not, and if not, what to do with INITSTR then: it will no longer be sent
> to tty immediately, but only after open() succeeds (which on !CLOCAL
> lines means "after Carrier Detect appears") - meaning that INITSTR
> can no longer be used to initialize modems.

I do not know how it is handled in current Linux kernel's but there
exist systems where using O_NONBLOCK on none local lines result in the
following behavior:

- open succeeds even if carrier detect signal is inactive
- output can be send and is buffered in tty serial line buffer (not send
to line yet)
- as soon as the carrier signal is raised the buffer content is send

So simply using O_NONBLOCK for none local lines doesn't allow to send
modem initialization codes.

You can do:

open with O_NONBLOCK
ioctl to set line to local mode (tcsetattr)
send modem initialization codes
wait for modem response
ioctl to set line to none local mode
send tty initialization codes or single CR (only buffered)
use tcdrain to wait for carrier raise (blocks until buffer empty)

May be you need to switch tty to none blocking mode before tcdrain
(system depended).

--
Harald


More information about the busybox mailing list