Hello all. I am trying to ramp up a new utility, which accepts a ^C from the user, outputs running processes (ran by the script), and asks for the user prompt. I have tried something very simple. I spawn a sleep process, via Expect, and every time that I hit ^C, I expect PERL to output a message. The code is:
require Expect; use strict; $SIG{'INT'}=sub {print "Al Bundy rules!\n";}; $SIG{CHLD}='IGNORE'; my $proc=Expect->spawn("sleep 10"); unless ($proc->expect(10,"Mommy")) { print "Stop selling women shoes\n"; }

Whe I hit ^c once, I get:

liord@analog2 238 > tester.pl Al Bundy rules! Stop selling women shoes
And the script exits. I have expected the scipt NOT to exit after one ^c, but after n presses (or 10 seconds). What am I doing wrong? PERL version is: This is perl, v5.8.8 built for x86_64-linux-thread-multi

In reply to INT signal kills process run with expect, when $SIG{'INT'} is set by ISAI student

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, details, 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, summary, 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.