[comp.os.minix] Non-blocking tty input

richard@aiai.ed.ac.uk (Richard Tobin) (02/20/91)

[Minix 1.5.10]

I see that read_write() in fs/read.c and dev_io() in fs/device.c take
account of the O_NONBLOCK flag, the latter setting TTY_FLAGS (with a
"temporary kludge" comment) in the message it passes to the tty task.
However do_read() in kernel/tty.c ignores this flag.  It seems that
something like

    if((m_ptr->TTY_FLAGS & O_NONBLOCK) &&
       (tp->tty_incount == 0 ||
	!(tp->tty_mode & (RAW | CBREAK)) && tp->tty_lfct == 0))
    {
	tty_reply(TASK_REPLY, m_ptr->m_source, m_ptr->PROC_NR, EAGAIN);
	return;
    }

would make it work (or the non-blocking flag could be passed on to
rd_chars()).

Any comments?

-- Richard

PS I didn't receive any response to my message about the stack not
being completely written out in core dumps if adjust() hasn't been
called recently enough.  Has this been fixed?

-- 
Richard Tobin,                       JANET: R.Tobin@uk.ac.ed             
AI Applications Institute,           ARPA:  R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk
Edinburgh University.                UUCP:  ...!ukc!ed.ac.uk!R.Tobin

agm@daphne.stl.stc.co.uk (Andrew G. Minter) (02/20/91)

In article <4186@skye.ed.ac.uk>, richard@aiai.ed.ac.uk (Richard Tobin) writes:
|> I see that read_write() in fs/read.c and dev_io() in fs/device.c take
|> account of the O_NONBLOCK flag, the latter setting TTY_FLAGS (with a
|> "temporary kludge" comment) in the message it passes to the tty task.
|> However do_read() in kernel/tty.c ignores this flag.

My Minix has had this patch for some time.  I think this is the way you're 
supposed to do it under POSIX and it doesn't break anything as far as I can
tell.

It is a big win for programs like kermit which can't do all it's tricks unless
it can find out whether there is keyboard input waiting.  It would also be 
useful for emacs!

I'd very much like to see this patch as standard.

Andrew
--
################################################################
# Andrew G. Minter            # Email: agm@stl.stc.co.uk       #
# Principal Research Engineer # Phone: +44 279 429531 ext 3165 #
# STC Technology Ltd          # Fax:   +44 279 441551          #
# London Road                 # ITN:   982-3165                #
# Harlow Essex CM17 9NA       # Telex: 81151 STL HW G          #
################################################################