trapping SIGABRT from perl on VMS

438 views Asked by At

Given kill.pl:

$SIG{INT} = sub { print "int\n" };
$SIG{TERM} = sub { print "term\n" };
$SIG{ABRT} = sub { print "abort\n" };

print "sleeping...\n";
sleep 60;

And kill.com:

$ perl kill.pl

And launching+aborting like so:

submit /log_file=kill.log kill.com

delete /entry=XXXXXX/noconfirm

The signal handlers do not get called. Similar code works on Linux when the process is killed.

kill.log just shows:

(19:58)$ perl kill.pl
sleeping...
%JBC-F-JOBABORT, job aborted during execution

I read the vmsperl documentation and tried some things from http://perldoc.perl.org/sigtrap.html. Is there a way to do this?

Note that if I call:

@kill.com

And do a CTRL+C, SIGINT is handled by kill.pl.

I added the perl tag in case someone knows if there is a way to tell perl to trap every signal which might be the one I'm interested in. My attempt was:

$SIG{$_} = \&subroutine for keys(%SIG);
2

There are 2 answers

0
Jim Black On

Is this an a VAX or Alpha system? I believe your 'delete' call may not be throwing an abort signal to your running job. Been too long since I've used it, but can't remember a tool that would throw a specific signal to a batch job - LIB$SIGNAL went from a process, not to it. You should try trapping the remaining signals from the 'error-signals' list on the sigtrap doc.

4
Craig A. Berry On

You're not sending a signal to the process -- you're instructing the queue manager to delete the process, which it does. I think the easiest way to do what you want is to use Perl to send the signal. Submit your job as before and use:

$ show system/batch

to find the pid of the job. You'll see something like this when the queue manager has assigned an entry of 572:

  Pid    Process Name    State  Pri      I/O       CPU       Page flts  Pages
00003EA1 BATCH_572       HIB      1      259   0 00:00:00.05       511    626  B

Send your signal like so to pid 0x3ea1, noting that the job notification indicates it completed rather than aborted:

$ perl -e "kill 'ABRT', 0x3ea1;"
$

Job KILL (queue SYS$BATCH, entry 572) completed

Look at your log file and you'll see these two lines at the end:

sleeping...
abort