[net.sources] idle ttys

rusty@sdcarl.UUCP (rusty c. wright) (07/31/85)

here's my candidate for making the tty appear to be in use.  it
doesn't use any special or magic system calls; it just depends upon
the ability to keep re-initiating a read on the tty.


# include <setjmp.h>
# include <signal.h>

jmp_buf		jbuf;

main() {
	extern int	sigalrm();
	char		ch;

	setjmp(jbuf);

	for (;;) {
		signal(SIGALRM, sigalrm);
		alarm(60);
		read(0, &ch, sizeof(ch));
	}
}

sigalrm() {
	signal(SIGALRM, sigalrm);
	longjmp(jbuf, 1);
}
-- 
	rusty c. wright
	{ucbvax,ihnp4,akgua,hplabs,sdcsvax}!sdcarl!rusty