Using IPC::Open2 on Windows for mission critical app

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'd like to start using IPC::Open2 on Windows Vista for a mission
critical application, but I'm a little cautious based on some postings
I've read. So far I've gotten it working without a hitch and have been
unable to manufacture any errors.

The way I have it working is by opening a single external process for
read/write access local to a class that handles all interaction with
this process. If all goes well, my application during its entire
lifespan will only have one instance of this external process running.

A class method writes to the process when necessary and another method
reads from it when necessary.

The read method uses a while() loop on the read file handle and then
uses "last" to exit the loop when a specific line of text is read. I
find this a little disconcerting as if anything goes wrong with the
process the while loop will just hang indefinitely, effectively
slaughtering my application.

As a failsafe, I've tried using $SIG to no avail, as the alarm()
doesn't appear useful when reading from the file handle.

    local $SIG = sub { die "Alarm went off!\n"; };
    while(<$readFH>) {
        last if m/^END$/;
        # do stuff

Does anyone have any ideas on a better failsafe? Of perhaps on a way
to get SIG ALRM working in the manner I've outlined? Or perhaps
someone could offer reassurances that the problems with IPC::Open2 on
Windows that I've hear about (which I'll reiterate that I've yet to
actually encounter) have been cleared up with new releases.

I'm currently using ActiveState binary build 820.

Re: Using IPC::Open2 on Windows for mission critical app

Quoted text here. Click to load it

AFAIK alarm doesn't work on Win32. Probably the simplest alternative is
to create a second thread which waits for the timeout and then kills the
first thread: you will need to test to make sure that a thread waiting
for IO can be killed.


Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 'Alcestis')        [ flame, and falls out of sight. ]

Site Timeline