|Problems? Is your data what you think it is?|
Alarms with ActivePerl do not work properlyby heiermann (Novice)
|on Jan 12, 2011 at 21:05 UTC||Need Help??|
heiermann has asked for the
wisdom of the Perl Monks concerning the following question:
I need your esteemed help on some wierd behaviour of alarms in ActivePerl. I am using v5.12.2 on Windows 2008 SP1 32bit.
I want to read from a long-running co-process until I am tired, then kill the co-process. I boiled down my code to the following snippet, replacing the real co-process with a dummy command:
I could not make the alarm work. I even tried unsafe signals. However, putting some tedious calculations somewhere inside the loop, will strangely solve the problem. Must this be considered as a bug?
I also experimented with threads and semaphores and finally found a work-around. But that would be an awful bunch of code for something quite obvious. Is there a state-of-the-art solution to this?
Thank you, Monks, for all your helpful answers. I will have to study and try for a while to understand all the implications of your proposals. The next thing, I will probably do, is using Win32::Job and/or Win32::Process. These sound quite reasonable and easy to interface, although, alas, they will impair portability of my code.