Possible to test ability to to kill process without doing it?

Possible to test ability to to kill process without doing it?

Post by Peter Seibe » Sat, 11 May 1996 04:00:00



I need to kill (actually kill -HUP) a process from within a perl
script. Is there any way for the script to test it's ability to do this
without actually doing it? My actual problem is a script that is cutting
off the logs from a web server. So it moves the logs and then restarts
the web server. But I don't want to move the logs unless I'm actually
going to be able to restart the server. So, any way to do this?

Thanks in advance.

-Peter

--

 
 
 

Possible to test ability to to kill process without doing it?

Post by David DeSimo » Sun, 12 May 1996 04:00:00



Quote:> I need to kill (actually kill -HUP) a process from within a perl
> script.  Is there any way for the script to test it's ability to do
> this without actually doing it?

The usual method is to kill the process with signal 0.  This causes the
usual permission checks to be made, but does not actually signal the
process.

--
David DeSimone      | "There is no reason for any individual to have a

 If I said it, it   |         DEC, World Future Society Convention, 1977
 must be my opinion |  PGP: 5B 47 34 9F 3B 9A B0 0D  AB A6 15 F1 BB BE 8C 44

 
 
 

Possible to test ability to to kill process without doing it?

Post by Peter Seibe » Fri, 17 May 1996 04:00:00





  >> I need to kill (actually kill -HUP) a process from within a perl
  >> script.  Is there any way for the script to test it's ability to do
  >> this without actually doing it?

  DD> The usual method is to kill the process with signal 0.  This causes
  DD> the usual permission checks to be made, but does not actually
  DD> signal the process.

Thanks to all the folks who pointed this out. Just to be clear -- does
the ability to kill 0 a process imply the ability to kill n the process
for all n (in the set of signals, obviously.)?

-Peter

--

# Organic Online is hiring Perl5/CGI programmers.
# Email or see <http://www.organic.com/Home/Info/Jobs/index.html>.

 
 
 

Possible to test ability to to kill process without doing it?

Post by Stephen M. Du » Tue, 21 May 1996 04:00:00


$I need to kill (actually kill -HUP) a process from within a perl
$script. Is there any way for the script to test it's ability to do this
$without actually doing it? My actual problem is a script that is cutting
$off the logs from a web server. So it moves the logs and then restarts
$the web server. But I don't want to move the logs unless I'm actually
$going to be able to restart the server. So, any way to do this?

   This is a Unix answer, not a Perl one ... but isn't that what kill -0
is for?
--

----------------------------------------------------------------------------
Manager, Technical Services                     United System Solutions Inc.
104 Carnforth Road, Toronto, ON, Canada M4A 2K7          (416) 750-7946 x251

 
 
 

1. How can kill all child processes without killing parent process ?

: Hi all UNIX expert,

: I am now writing a shell script to kill all child processes of a
: particular process.  I have written the following
: script:

: ps -ef | grep o\\ra  | awk '{print $2}' | xargs kill

: where ora is the name of the parent process

: However, this shell script only kills out the parent process,
: Does anyone know how to kill all child process without
: killing that parent process ? Please advise !!! Many thanks !!!
: Have a nice UNIX day !!!

you will have to read all matching processes and only kill the last in the
chain by using PID and PPID; unfortunately we can not assume that the
child is the process with the highest PPID:
assume $2=PID , $3=PPID ( coming from   ps -ef | grep o\\ra  | grep -v grep )

{
        PID[ $2 ]=""
        PPID[ $3 ]=""

END{
# process ids which are also parents should be deleted
        for( pid in PPID ) if ( pid in PID ) delete PID[ pid ]
        for( pid in PID ) { do_whatever_you_like_on_your_own_risk( pid ) }
        }

function do_whatever_you_like_on_your_own_risk( param ){
        code...
        }

2. PPP -- Howto dial on demand ?

3. A method to kill process that cannot be killed even with `kill -9'.

4. How can I change the screen saver for X-Server

5. How to kill process which not killed by 'kill' ?

6. Diamond Stealth and True Color Mode

7. restart X without client kills, possible?

8. fortune for Solaris 2

9. test test test test test test test

10. How to Kill Process and Its sub-process and its sub-process??

11. Was: User without process (how to kill him)

12. Is it possibile create a core file during the execution of a process without kill it ?

13. Is it possible to kill a <defunct> process?