in reply to Re^13: Print inside SIGNALS (updated)
in thread Print inside SIGNALS
G'day haukex,
Following your CB request, I ran this a few times for you. Firstly, here's what I'm using:
$ uname -a Linux ibm-laptop.diversityarrays.com 4.1.34-33-default #1 SMP PREEMPT +Thu Oct 20 08:03:29 UTC 2016 (fe18aba) x86_64 x86_64 x86_64 GNU/Linux $ perl -v | head -2 | tail -1 This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-li +nux-thread-multi
"I've tried it lots of times, and no matter how long I wait to input something (or nothing) and hit enter, the output is invariably 2.
I got different results: ran it four different ways; only got 2 once.
I wrapped your one-liner in date commands to indicate the wait time; however, this didn't work when I issued an interrupt (^C). Here's the runs:
Hitting Enter almost immediately:
$ date; perl -wMstrict -le '$a=time;$SIG{ALRM}=sub{$b=time};alarm 2;<> +;print $b-$a'; date Sat Jul 21 05:55:19 AEST 2018 Use of uninitialized value $b in subtraction (-) at -e line 1, <> line + 1. -1532116519 Sat Jul 21 05:55:20 AEST 2018 $
Hitting Enter after several seconds:
$ date; perl -wMstrict -le '$a=time;$SIG{ALRM}=sub{$b=time};alarm 2;<> +;print $b-$a'; date Sat Jul 21 05:56:58 AEST 2018 2 Sat Jul 21 05:57:05 AEST 2018 $
Hitting Ctrl-C almost immediately:
$ date; perl -wMstrict -le '$a=time;$SIG{ALRM}=sub{$b=time};alarm 2;<> +;print $b-$a'; date Sat Jul 21 05:59:28 AEST 2018 ^C $
Hitting Ctrl-C after several seconds:
$ date; perl -wMstrict -le '$a=time;$SIG{ALRM}=sub{$b=time};alarm 2;<> +;print $b-$a'; date Sat Jul 21 06:00:13 AEST 2018 ^C $
Finally, please consider this response in isolation. I did start reading this thread when it first appeared; I stopped doing that when umber-hued material appeared to be headed for a cooling device. I followed the link you provided in the CB and replied directly; I didn't review any part of the thread before doing so.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^15: Print inside SIGNALS
by haukex (Archbishop) on Jul 20, 2018 at 20:48 UTC |