<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Perl Question in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838671#M100677</link>
    <description>Oh, and I should add that the truly paranoid programmer also knows that signal handlers should be short and sweet. Do no more than absolutely necessary and then return. It depends upon how re-entrant the code is at the lowest levels -- and this applies to C and Perl.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 07 Aug 2006 12:14:53 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2006-08-07T12:14:53Z</dc:date>
    <item>
      <title>Perl Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838666#M100672</link>
      <description>Hello Perl Experts:&lt;BR /&gt;&lt;BR /&gt;How do I temporarily replace a signal handler inside a perl function and then restore the previous signal handler?&lt;BR /&gt;&lt;BR /&gt;TIA,&lt;BR /&gt;Steve</description>
      <pubDate>Mon, 07 Aug 2006 11:33:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838666#M100672</guid>
      <dc:creator>Steve Start</dc:creator>
      <dc:date>2006-08-07T11:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838667#M100673</link>
      <description>This is rather easy if I correctly understand your question.&lt;BR /&gt;&lt;BR /&gt;my $Flag = 0;&lt;BR /&gt;&lt;BR /&gt;sub my_local_handler&lt;BR /&gt;{&lt;BR /&gt;  $SIG{INT} = \&amp;amp;my_local_handler; &lt;BR /&gt;  ++$Flag;&lt;BR /&gt;  return(0);&lt;BR /&gt;} # my_local_handler&lt;BR /&gt;&lt;BR /&gt;sub my_function&lt;BR /&gt;{&lt;BR /&gt;  local $SIG{INT} = \&amp;amp;my_local_handler;&lt;BR /&gt;  ...&lt;BR /&gt;  ...&lt;BR /&gt;  return(0);&lt;BR /&gt;}  # my_function&lt;BR /&gt;&lt;BR /&gt;The key is the "local" scope. When my_function falls out of scope then the signal handler for SIGINT reverts to its prior value. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Aug 2006 11:39:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838667#M100673</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-08-07T11:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838668#M100674</link>
      <description>Hi Steve:&lt;BR /&gt;&lt;BR /&gt;Use a 'local' declaration for your handler.  For instance:&lt;BR /&gt;&lt;BR /&gt;sub mything {&lt;BR /&gt;  local $SIG{INT} = \&amp;amp;myhandler;&lt;BR /&gt;  ...&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Aug 2006 11:41:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838668#M100674</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-07T11:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838669#M100675</link>
      <description>Thanks guys. That was very quick.&lt;BR /&gt;&lt;BR /&gt;A. Clay, why do you do this inside the signal handler?&lt;BR /&gt;&lt;BR /&gt;sub my_local_handler&lt;BR /&gt;{&lt;BR /&gt;$SIG{INT} = \&amp;amp;my_local_handler;&lt;BR /&gt;++$Flag;&lt;BR /&gt;return(0);&lt;BR /&gt;} # my_local_handler&lt;BR /&gt;&lt;BR /&gt;It looks like you are setting the signal handler to itself. Was this a typo?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Steve&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Aug 2006 12:02:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838669#M100675</guid>
      <dc:creator>Steve Start</dc:creator>
      <dc:date>2006-08-07T12:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838670#M100676</link>
      <description>No Steve, t'weren't no typo nor was it no mistake neither. It was (probably) paranoia on my part leftover from signal handling in C in the dim mists of time. Consider what would happen if the process received another SIGINT while already processing a SIGINT. Resetting the signal handler to itself does no harm but is probably not necessary in modern versions of UNIX and Perl but the paranoid programmer will include the signal redirection in order to make truly portable code.</description>
      <pubDate>Mon, 07 Aug 2006 12:11:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838670#M100676</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-08-07T12:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838671#M100677</link>
      <description>Oh, and I should add that the truly paranoid programmer also knows that signal handlers should be short and sweet. Do no more than absolutely necessary and then return. It depends upon how re-entrant the code is at the lowest levels -- and this applies to C and Perl.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Aug 2006 12:14:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/3838671#M100677</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-08-07T12:14:53Z</dc:date>
    </item>
  </channel>
</rss>

