From: Craig A. Berry Date: Sat, 23 Mar 2002 23:23:00 +0000 (-0600) Subject: extend use of home-grown kill() on VMS X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=05c058bc16a76532007427c68eaafb53a23230dc;p=p5sagit%2Fp5-mst-13.2.git extend use of home-grown kill() on VMS From: "Craig A. Berry" Message-Id: p4raw-id: //depot/perl@15459 --- diff --git a/configure.com b/configure.com index d7d0479..cfa695c 100644 --- a/configure.com +++ b/configure.com @@ -4943,24 +4943,29 @@ $ GOSUB compile $ nv_preserves_uv_bits = tmp $ ENDIF $! -$ echo4 "Checking whether your kill() uses SYS$FORCEX..." +$ echo4 "Checking if kill() uses SYS$FORCEX or can't be called from a signal handler..." $ kill_by_sigprc = "undef" $ OS $ WS "#include " $ WS "#include " $ WS "#include " -$ WS "void handler(int s) { printf(""%d\n"",s); } " +$ WS "void handler1(int s) { printf(""%d"",s); kill(getpid(),2); }" +$ WS "void handler2(int s) { printf(""%d"",s); }" $ WS "main(){" $ WS " printf(""0"");" -$ WS " signal(1,handler); kill(getpid(),1);" +$ WS " signal(1,handler1);" +$ WS " signal(2,handler2);" +$ WS " kill(getpid(),1);" +$ WS " sleep(1);" +$ WS " printf(""\n"");" $ WS "}" $ CS $ ON ERROR THEN CONTINUE $ GOSUB compile -$ IF tmp .NES. "01" +$ IF tmp .NES. "012" $ THEN -$ echo4 "Yes, it does." -$ echo4 "Checking whether we can use SYS$SIGPRC instead" +$ echo4 "Yes, it has at least one of those limitations." +$ echo4 "Checking whether we can use SYS$SIGPRC instead..." $ OS $ WS "#include " $ WS "#include " diff --git a/vms/vms.c b/vms/vms.c index 47716c3..4ae5541 100644 --- a/vms/vms.c +++ b/vms/vms.c @@ -1096,13 +1096,18 @@ Perl_my_sigaction (pTHX_ int sig, const struct sigaction* act, #ifdef KILL_BY_SIGPRC #include -/* okay, this is some BLATENT hackery ... - we use this if the kill() in the CRTL uses sys$forcex, causing the +/* We implement our own kill() using the undocumented system service + sys$sigprc for one of two reasons: + + 1.) If the kill() in an older CRTL uses sys$forcex, causing the target process to do a sys$exit, which usually can't be handled gracefully...certainly not by Perl and the %SIG{} mechanism. - Instead we use the (undocumented) system service sys$sigprc. - It has the same parameters as sys$forcex, but throws an exception + 2.) If the kill() in the CRTL can't be called from a signal + handler without disappearing into the ether, i.e., the signal + it purportedly sends is never trapped. Still true as of VMS 7.3. + + sys$sigprc has the same parameters as sys$forcex, but throws an exception in the target process rather than calling sys$exit. Note that distinguishing SIGSEGV from SIGBUS requires an extra arg