Swarup Baran wrote:
> What i need to handle is if this perl process gets a kill process
> either because of a manual kill or machine reboot etc. I should be
> able to trap it, clean up if any resources and then EXIT.
My understanding is that SIGKILL is very specifically *not* trappable.
Otherwise, it would be possible to write a program that simply cannot
be stopped (short of rebooting the machine). To wit:
$ perl -e'$SIG{$_} = sub { print "Caught SIG$_[0]\n" } for keys %SIG; 1
while 1' &
[1] 18338
$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGEMT

SIGFPE
9) SIGKILL 10) SIGBUS 11) SIGSEGV 12) SIGSYS
13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGUSR1
17) SIGUSR2 1

SIGCHLD 19) SIGPWR 20) SIGWINCH
21) SIGURG 22) SIGIO 23) SIGSTOP 24) SIGTSTP
25) SIGCONT 26) SIGTTIN 27) SIGTTOU 2

SIGVTALRM
29) SIGPROF 30) SIGXCPU 31) SIGXFSZ 32) SIGWAITING
33) SIGLWP 34) SIGFREEZE 35) SIGTHAW 36) SIGCANCEL
37) SIGLOST
$ kill -1 18338
Caught SIGHUP
$ kill -2 18338
Caught SIGINT
$ kill -3 18338
Caught SIGQUIT
$ kill -4 18338
Caught SIGILL
$ kill -9 18338
[1]+ Killed perl -e'$SIG{$_} = sub { print "Caught SIG$_[0]\n"
} for keys %SIG; 1 while 1'
$ ps -u plalli
PID TTY TIME CMD
17896 pts/4 0:00 bash
$
> Is it possible to do so? An urgent reply would be appreciated.
That's just plain rude. If you need urgency, you hire a consultant.
If you want free help, you accept it whenever someone feels like giving
it to you.
Paul Lalli