>>>>> "RN" == Ranga Nathan <[EMAIL PROTECTED]> writes:

  RN> I need to remember the last record processed no matter how a script
  RN> completes - kill or stop.
  RN> My perl is a little rusty now. The following coding does not seem to work.

  RN> $SIG{KILL} = $SIG{STOP} = $SIG{TERM} = $SIG{__DIE__} = sub {
  RN> system ("echo $last_rec > /tmp/ftpscan");die "Now I am
  RN> stopping";};

  RN> When  I kill my script with Ctrl-C, I do not see the output of the "die".

where is $SIG{INT}? ^C generates SIGINT and not those others. also you
can't ever catch SIGKILL as it is specified that way so don't even waste
time giving it a handler. i forget what SIGTERM is and i doubt you need
it. SIGSTOP is used for parent/child process stuff IIRC so again you
don't need to set it.

also beware if $last_rec has any shell metchars or leading/trailing
whitespace as you may not get what you want. why not just open a file
and write it from perl? use File::Slurp and it becomes trivial

use File::Slurp ;

$SIG{INT} = $SIG{__DIE__} = sub {
        write_file( '/tmp/ftpscan', $last_rec ) ;
        die 'i am died now' ;
} ;

if $last_rec is binary, then add the binmode option.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to