1

Here is my testing environment:

root@redhat89195 bin]# ./perl -v
This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-thread-multi
.....

Code snippet:

$SIG{INT}=sub{
         print "1234\n";
         print getc(STDIN);
         print "4444\n";
};

print "5678\n";
print getc(STDIN);

after running the program, "5678" is printed first, then waiting for inputs, then I enter "eeee" followed by "ctrl-c", then the handler continuously prints "1234" and "4444" with skipping getc function in the handler, then it hangs waiting inputs (I guess it is the getc outside the handler which is still waiting inputs), I enter "q", it prints "q".

So my question is:

  1. why doesn't the getc function in the handler work out? It seems the issue doesn't exist in other perl releases.
  2. How can it be solved to make the getc function in the handler work out?

0 Answers0