Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Print inside SIGNALS

by ikegami (Patriarch)
on Jul 16, 2018 at 14:04 UTC ( [id://1218578]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Print inside SIGNALS
in thread Print inside SIGNALS

Then something is really messed up with your box. Unless you didn't actually run Corion's program?

Replies are listed 'Best First'.
Re^4: Print inside SIGNALS
by pedrete (Sexton) on Jul 16, 2018 at 19:43 UTC

    This code does not work...

    alarm 2; $SIG{ALRM} = \&Finish; my $a=<>; sub Finish { print "Timeout reached"; }

    This code does not work either...

    alarm 2; $SIG{ALRM} = \&Finish; while (1==1){}; sub Finish { print "Timeout reached"; }

    So i guess many calls are not interrumptibles... am i right>?

      So i guess many calls are not interrumptibles... am i right?

      I don't think that's the problem here - see my reply to your nearly identical post here.

      First snippet: <> can't be interrupted because there's no way to check <> for errors. However, the signal handler does get called once it returns.

      Second snippet: There's nothing to interrupt here, so the signal handler gets called immediately. However, since the program has no way of terminating the program cleanly, the message will never leave STDOUT's buffer to the underlying file system handle.

        First snippet: <> can't be interrupted because there's no way to check <> for errors. However, the signal handler does get called once it returns.

        At least on my machine (Linux), it seems to be the same buffering issue...

        $ perl -wMstrict -e 'alarm 2; $SIG{ALRM}=sub{ print "Timeout reached" };<>' ^C $ perl -wMstrict -e 'alarm 2; $SIG{ALRM}=sub{ print "Timeout reached\n" };<>' Timeout reached ^C $ perl -wMstrict -e 'alarm 2; $SIG{ALRM}=sub{ print STDERR "Timeout reached" };<>' Timeout reached^C

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-03-29 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found