Need Non-Blocking Terminal Input Function For Berkeley 4.2

Clayton Cramer cramer at kontron.UUCP
Thu Jan 23 04:27:33 AEST 1986


Does anyone know of a way to do read from a terminal under Berkeley 4.2 UNIX
so that after a specified number of seconds control is returned to the
program if there is no response?  Right now I'm forking off of the main
program, and having the child process do the read, with the parent setting
an alarm to interrupt the child after a certain number of seconds.  This
works, but it's devilishly difficult to debug using dbx.  Alternate 
techniques would be appreciated.

Please don't suggest using alarm within the same process to interrupt
a read -- to quote SIGNAL(3C):

	If a caught signal occurs during certain system calls, causing
        the call to terminate prematurely, the call is automatically
        restarted.  In particular, this can occur during a _read_ or
        _write_(2) on a slow device (such as a terminal; but not a
        file) and during a _wait_(2).
        
In short, the one time it would be most useful!



More information about the Comp.unix.wizards mailing list