Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: sending signal to self with kill on windows (updated);

by BrowserUk (Patriarch)
on Dec 30, 2012 at 05:54 UTC ( [id://1010893]=note: print w/replies, xml ) Need Help??


in reply to sending signal to self with kill on windows

Why wasn't the %INC handler called?

What the heck is an " %INC handler"?

Update: assuming you mean %SIG handler; I think this demonstrates that the Perl Windows sig emulation has code to prevent a process from attempting to signal itself:

C:\test>start /b perl -E"say $$; sleep 10000" C:\test>192904 C:\test>perl -E"kill 21, 192904 or die $^E" Terminating on signal SIGBREAK(21) C:\test>perl -E"kill 21, $$ or say $^E; say 'ending';" The parameter is incorrect ending

It doesn't make a great deal of sense to signal yourself to invoke a subroutine when you can just:

C:\test>perl -wE"$SIG{BREAK}=sub{ say 'BREAKing' }; &{$SIG{BREAK}}; sa +y 'ending'; " BREAKing ending

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: sending signal to self with kill on windows (recursive sig-handler)
by LanX (Saint) on Dec 30, 2012 at 21:12 UTC
    > I think this demonstrates that the Perl Windows sig emulation has code to prevent a process from attempting to signal itself:

    Definitely! I had this at one of my projects...

    My face and all my hairs went pale, when I realized that a young colleague of mine called warn within $SIG{__WARN__}-handler.

    As it turned out Perl was (since 5.8 IIRC) idiot proof. It locally resets signal handler redirections before calling them.

    My colleague insisted that I exaggerated, because she "tested" (i.e ran) it once before committing into production.

    Her warn did depend on an if clause and "production" meant a central module of a mod-perl environment...

    Cheers Rolf

    UPDATE:

    from warn

    Most handlers must therefore make arrangements to actually display the warnings that they are not prepare +d to deal with, by calling "warn" again in the handler. Not +e that this is quite safe and will not produce an endless loop +, since "__WARN__" hooks are not called from inside one.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1010893]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-03-28 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found