[comp.bugs.4bsd] tty selects for input in background processes

aweinste@bbn.com (Anders Weinstein) (07/29/87)

In both 4.2 & 4.3, a select on a tty will return with input ready *even if*
the selecting process is in the background and can't actually read the typed
line or character.  The FIONREAD ioctl has the same defect.  I place the bug
in the "ttnread" routine, which is missing the appropriate check on the
process groups.

This has stymied my attempt to write a user-ftp-like program which must
multiplex handling tty commands with network input (and is very likely to be
kept in the background while idle). I know I can avoid blocking on the
background read attempts, but I don't want the idle process to wake up every
time the user types a line in the foreground.  I'm considering spawning
another process (/bin/cat comes to mind) just to funnel me the tty input
through a pipe -- this all just so I can do a select on it. Any alternative
suggestions would be welcome.

Anders Weinstein
BBN Labs