I don't care much about what ikagami said exactly

That's a strange thing to say when that's all this sub-thread is about. Please re-read the thread starting from here.

ctrl-c pressed < 2 seconds

No, that's exactly the thing I have an issue with: I certainly have a dense moment now and then, but I'm not dumb enough to set an alarm for two seconds upon which something is to be printed, kill the program before the two seconds is up, and then use this as my evidence that nothing was printed. And I'm going to take special care when I'm pointing out a potential mistake to a Monk whose technical knowledge is much deeper than mine and who is almost always right in his posts.

And it should be obvious to anyone that I didn't hit Ctrl-C within the first two seconds if they had actually run my first two one-liners (again, assuming their system behaves the same as mine). Which is why I posted them in the first place!

but you did kill the program ... As far as I'm concerned that is the reason why your example does not print anything.

Then you are making this same incorrect (and insulting) assumption that ikegami did. Did you try out my most recent one-liner that has nothing to do with SIGINT?

STDOUT ... matters everything

No, it does not.

$ perl -e '$x=time; $SIG{ALRM}=sub{$y=time; close STDIN}; alarm 2; <>; print STDERR $y-$x," ",time-$x,"\n"' 2 2

Just to make it clear: This shows how <> is interrupted by $SIG{ALRM}, without STDOUT being involved at all. Which is why I think that the first snippet posted by pedrete here is just suffering from buffering (but I'm always willing to be proven wrong).

$SIG{'INT'} = sub { exit(0) } ;

This misses the point, because of course the output buffers get flushed on exit. With buffering issues, the question is not whether something gets printed, but when. And perhaps you overlooked that the OP confirmed that it was a buffering issue all along.

I've said all I can say until someone shows some actual evidence to the contrary.


In reply to Re^14: Print inside SIGNALS by haukex
in thread Print inside SIGNALS by pedrete

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.