to KILL or NOT to KILL - help! 
Author Message
 to KILL or NOT to KILL - help!

Hi,

HELPP!!!! I have a perl script running in a directory - does anyone know how I
can delete the contents of the directory with the perl script whilst the script
is running ?

I would deeply appreciate (urgently) some help - thanks beforehand

Sattar



Fri, 27 Apr 2001 03:00:00 GMT  
 to KILL or NOT to KILL - help!
Hi,

assuming you're on Unix, use signals (perldoc perlipc).

In your script do this:

#!/usr/bin/perl -w

my gotASignal = 0;

sub usrHandler
   {
      gotASignal++;
      $SIG{'USR1'} = \&usrHandler;
   }

sub main
   {
       $SIG{'USR1'} = \&usrHandler;

       while ($something) {
        ## do something
        ## when you're not doing something, check if gotASignal > 0
        if (gotASignal) {
           gotASignal = 0;
           ## clear the directory
        }
       }
   }

main;

Then, when you want to have the script clear the directory, find the
process id of your script (ps), then:

kill -USR1 <process id of your script>

That should work.

Cheers.

--
-----------------------------------------------------------------------------
      *My wife says I never listen to her  ...or something like that. *



Mon, 07 May 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. TO KILL or NOT to kill a process

2. Need Help: fork / kill / kill 0

3. BIZARRE: killing window kills bg perl process

4. Kill in perl not working.

5. Newsreader/kill-read based on body, not header?

6. kill with SIGTERM not working

7. Kill Signals going to forked System command not Perl script

8. kill not ok?

9. Help: To Kill an Object

10. Help! exec and kill

11. OT: Help to kill a spammer...

12. Help... RE's killing me :)

 

 
Powered by phpBB® Forum Software