logging out a terminal

r.peterson roe at sobmips.UUCP
Wed Oct 25 14:38:48 AEST 1989


>From article <1001 at quack.UUCP>, by mrapple at quack.UUCP (Nick Sayer):
> I am (re-)writing an idle daemon for this beast, and am running
> into trouble. The original code I'm hacking to bits calls for
> a routine "vhangup()." How can I write this routine?
> 
> Do I have to search through the process table looking for all processes
> running on a certain terminal and send them SIGKILL? That seems
> a bit draconian.
> 
Depends on what version of kill(2) you've got.  I can't remember if
V7 (especially unisoft) supports this, but -- according to the
sysV man(2)kill:

 - kill(pid,sig)
 - 
 [stuff deleted]
 - 
 -      If pid is negative but not -1, sig will be sent to all
 -      processes whose process group ID is equal to the absolute
 -      value of pid.

So, the trick is finding the login-spawned shell process (ie the process
group leader) associated with the set of jobs you want to kill.
(Look for a ksh,csh,sh with PPID=1).
Given that, just negate that jobs' process id (it will almost always
be the process group leader for the entire login session), and try
	kill(-pid,9)
to terminate all processes associated with that terminal with
extreme prejudice.

Good luck.

-- 
If the brain were so simple we understood it|Roe Peterson
We would be so simple we couldn't.          |{attcan,mcgill-vision}!sobeco!roe



More information about the Comp.unix.questions mailing list