Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: joost@cadlab.de (Michael Joosten)
Subject: Re: Having trouble kill()ing processes from C code.
Date: 16 Apr 93 18:55:40	[thread overview]
Message-ID: <JOOST.93Apr16185540@ori.cadlab.de> (raw)
In-Reply-To: wws@iscp.bellcore.com's message of Wed, 14 Apr 93 12:46:28 GMT

In article <1993Apr14.124628.20840@porthos.cc.bellcore.com> wws@iscp.bellcore.com (Wayne Scott) writes:

   keeping track of the PIDs so I can terminate them when the application is shut
   down.  I can NOT terminate the xterm PIDs with kill(pid, SIGTERM); but I CAN
   terminate them with kill(pid, SIGKILL).  However, when an rlogin is done from
   the xterm, the rlogin is still active AFTER the xterm has been killed.
   When I logout of the xterm windows with <ctrl-d>, the xterm AND rlogin go away.

If you have xterm sources, you can easily see that there is something
'magically' going on for System V. I had the same problem with a 'tool server'
that creates new processes on remote requests. Worked fine on Sun, but on
a SGI one could not kill the xterms unless with brutal force, especially not
with INTR, HUP and QUIT. My solution was to create a new process group for
the forked process, like this:

            OS_signal(SIGHUP, (OS_SigType)SIG_DFL);
            OS_signal(SIGINT, (OS_SigType)SIG_DFL);
            OS_signal(SIGQUIT, (OS_SigType)SIG_DFL);
            OS_signal(SIGHUP, (OS_SigType)SIG_DFL);
            
            // ensure that the exec'ed process has its own group,
            // otherwise some programms in SysVR3 will ignore
            // the terminal-signals (SIGHUP, SIGINTR, SIGQUIT, SIGTERM)
            // like xterms on SGI IRIX..... (mj)
            
            setsid(); 
            
            execvp( path, &argv[0] );

This is not an OSF feature, but rather common to System V and POSIX - or
xterm's handling of signals in case of beeing compiled for SysV. The code
checks if the pid == pgrp and only then reacts on the signals (as I recall..) 

Hope that helps,   Michael
 
--
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Michael Joosten   |       Tel.  : (+49) (+) 5251-284 120                 |
| CADLAB            |       Fax   : (+49) (+) 5251-284 140                 |
| Bahnhofstr. 32    |       E-Mail: joost@cadlab.de                        |
| D-4790 Paderborn  |        	    ...!uunet!unido!cadlab!joost           | 
| FRG               | Mass mail to: joost@pbinfo.uni-paderborn.de          |
|--------------------------------------------------------------------------|
| CADLAB is a cooperation between Uni-GH Paderborn & SNI AG                |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


      reply	other threads:[~1993-04-16 22:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-04-14 12:46 Having trouble kill()ing processes from C code Wayne Scott
1993-04-16 22:55 ` Michael Joosten [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox