Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^9: Strawberry Perl and alarm() on Windows

by afoken (Chancellor)
on May 24, 2015 at 20:50 UTC ( [id://1127616]=note: print w/replies, xml ) Need Help??


in reply to Re^8: Strawberry Perl and alarm() on Windows
in thread Strawberry Perl and alarm() on Windows

But PERL_SIGNALS does not affect the operating system in any way. Linux deliveres SIGALRM as it would for any other program. That means that the flock() system call (deep inside the perl flock() function) will be interrupted and will return EINTR immediately after the signal handler (deep inside the perl executable, not $SIG{'ALRM'}) has returned.

Sorry, but I think you're wrong. The signal is "delivered" to the process, but the process can block, or ignore it or (as perl since 5.8.1) defer it.

We are talking about a signal that has a custom signal handler set up. Blocking or ignoring is completely irrelevant for this discussion. But yes, the kernel runs through some code that decides if how the signal is handled. Options are:

  • Call a user mode function (signal handler), this is what happens here.
  • Put it into a queue (blocked signal, becomes pending signal)
  • Ignore it (ignored signals)
  • Call the default handler inside the kernel. What happens here depends on the actual signal:
    • Terminate the process (SIGHUP, SIGINT, SIGTERM, SIGALRM, and others)
    • Ignore the signal (SIGCHLD, SIGURG, SIGWINCH, and others)
    • Terminate the process and dump core (SIGQUIT, SIGILL, SIGFPE, SIGBUS, and others)
    • Stop the process (SIGSTOP, SIGTSTP and others)
    • Continue the process if it currently stopped (SIGCONT)

This happens during delivery, before user mode code is called.

For some signals (SIGKILL and SIGSTOP), the only option is the default handler. The kernel will enforce that handler, even if you have managed to set up blocking, ignoring, or a signal handler for those signals.

What you call "defer" is not a special option for signal handling, but just a user mode signal handler that only sets a flag, combined with code to poll that flag later. This happens completely in user mode, inside the perl executable.

But, this is way outside my knowledge base

Yes, it seems so.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^10: Strawberry Perl and alarm() on Windows
by BrowserUk (Patriarch) on May 24, 2015 at 20:57 UTC
    What you call "defer" is not a special option for signal handling,

    It's not my term, but rather that of the perl documentation: Deferred signals.

    This happens completely in user mode, inside the perl executable.

    Yes. But it still happens. Thus, Perl defers taking any action on the signal, until the current opcode has completed. That's how "safe signals" work.

    But, this is way outside my knowledge base. -- Yes, it seems so.

    It always amazes me how little the vast majority of linux users know about the way their OS works.


    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". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-19 19:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found