Logout from inside a program - help!

Chris Torek chris at umcp-cs.UUCP
Wed Sep 26 11:27:48 AEST 1984


The following subroutine will log you out of a 4.1 or 4.2BSD system
(don't know about 2.9 but probably that too):

	logout () {
		(void) lseek (0, -16L, 0);
		exit (0);
	}

The reason (in case you care) is that lseeks to negative offsets
are allowed on character special devices (to accomodate major device
#3) yet reads from these with a negative offset will (with the notable
exception of cdevsw[3] of course) fail.

The C shell, upon getting a failed read, quickly gives up and logs
you out.  (Presumably the Bourne shell does the same thing.  I haven't
tried it.)
-- 
(This page accidently left blank.)

In-Real-Life: Chris Torek, Univ of MD Comp Sci (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.unix.wizards mailing list