Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
What OS is it running in? I gladly forgot most about Autosys after quitting $job - 1.

The following runs in Linux and reacts to signals as expected:

#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; local $SIG{USR1} = sub { say STDERR "Signal 1 caught."; alarm 0; }; local $SIG{USR2} = sub { say STDERR "Bye!"; exit }; my $sum = 0; while (1) { $sum += $_ for 1 .. 100; say $sum; say STDERR scalar localtime, " Sleeping..."; sleep 10; say STDERR scalar localtime, " Ready!"; }

A sample session:

▏~ $ 11111522.pl &
[1] 28265
5050
Fri Jan 17 15:28:04 2020 Sleeping...
Fri Jan 17 15:28:14 2020 Ready!
10100
Fri Jan 17 15:28:14 2020 Sleeping...
▏~ $ kill -USR1 28265
Signal 1 caught.
Fri Jan 17 15:28:17 2020 Ready!
15150
Fri Jan 17 15:28:17 2020 Sleeping...
▏~ $ kill -USR2 28265
Bye!
[1]+  Done                    11111522.pl
▏~ $

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

In reply to Re: Signal to a sleeping Perl program by choroba
in thread Signal to a sleeping Perl program by jerryhone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (4)
    As of 2021-02-27 19:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?