Your skill will accomplish
what the force of many cannot
Is the signal handler supposed to work like this?by dpmott (Scribe)
|on Aug 30, 2008 at 00:26 UTC||Need Help??|
dpmott has asked for the
wisdom of the Perl Monks concerning the following question:
The short question is this: should spawning a thread change how signal handlers behave? See below for a working code snippet.
So, I was banging my head against the keyboard trying to remember how to read in a series of lines from STDIN with Win32 ActivePerl. After much googling, I realize that I've only ever gotten characters with Term::ReadKey, and that isn't even close to what I wanted. Apparently, nothing is.
All I wanted to do was this, and be able to type ctrl-D to signify that I was done:
(Somebody let me know if I missed the obvious boat here; I couldn't find the way to do this.)
So, I decided to go with ctrl-C:
Hmmm... that doesn't work either. It kills my script.
I soon came to realize that I'm using that nifty new Perl v5.8.8 with "safe" signals, and I suspect that this was getting in the way. Sadly, Perl::Unsafe::Signals isn't available via ppm for ActivePerl, so I didn't get to find out either way.
What I did discover, quite by accident was that spawning a thread changes the behavior of the signal handler:
So, I'm left wondering if that was supposed to work that way?