Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site bu-cs.UUCP
Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!harpo!decvax!genrad!panda!talcott!harvard!bu-cs!root
From: root@bu-cs.UUCP (Barry Shein)
Newsgroups: net.unix-wizards
Subject: Re: How can I log a user out?
Message-ID: <440@bu-cs.UUCP>
Date: Sun, 23-Jun-85 21:26:21 EDT
Article-I.D.: bu-cs.440
Posted: Sun Jun 23 21:26:21 1985
Date-Received: Wed, 26-Jun-85 05:21:51 EDT
References: <327@muddcs.UUCP>
Organization: Boston Univ Comp. Sci.
Lines: 49
Keywords: logout hangup

>From: david@muddcs.UUCP (David Goebel)
>Subject: How can I log a user out?
>Date: Wed, 19-Jun-85 19:17:08 EDT
>
>Does anyone out there know of a quick way to log a user out from a C 
>program without rummaging through memory for the pid of the login shell?

I'm not sure exactly what you are after but this is a program I
often use that just toggles DTR on the terminal line. I figure
that's the best I can do being as Ma Bell might have done accidently
anyhow: (the timeout's in case I get hung on carrier or something.)
[dtr.c follows, a trivial program, obviously won't work with hard-wired
lines but you should probably get rid of those anyhow :-]

----------

#include 
#include 
#include 
#define TIMOUT 30
usage(s) char *s ;
{
	fprintf(stderr,"Usage: %s terminal-line\n",s) ;
	exit(1) ;
}
tock()
{
	fprintf(stderr,"Timed out...\n") ;
	exit(1)	;
}
main(argc,argv) int argc ; char **argv ;
{
	int fd ;

	signal(SIGALRM,tock) ;
	alarm(TIMOUT) ;
	if(argc != 2) usage(*argv) ;
	if((fd = open(*++argv,2)) < 0)
	{
		perror(*argv) ;
		exit(1) ;
	}
	if(ioctl(fd,TIOCCDTR,0) < 0)
	{
		perror(*argv) ;
		exit(1) ;
	}
	exit(0) ;
}