Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

$SIG{ALRM} timeout and Win32::DDE::Client hangs?

by TedPride (Priest)
on Nov 05, 2007 at 23:45 UTC ( [id://649115]=perlquestion: print w/replies, xml ) Need Help??

TedPride has asked for the wisdom of the Perl Monks concerning the following question:

eval { local $SIG{ALRM} = sub { die "Unable to initiate Zip4 connection"; + }; alarm(1); $zip4 = new Win32::DDE::Client('ZP4', 'Addresses'); $SIG{ALRM}->() if $zip4->Error; alarm(0); }; die $@ if $@;
This works just fine when I replace the $zip4 parts of the code with something else, like say sleep(10). However, if the ZP4 application doesn't happen to be running already and ready for connections, it just sits there and hangs rather than dying after 1 second like it's supposed to. Why?

Replies are listed 'Best First'.
Re: $SIG{ALRM} timeout and Win32::DDE::Client hangs?
by BrowserUk (Patriarch) on Nov 06, 2007 at 01:36 UTC

    See the POD:

    Timeout (NEWVALUE)

    If NEWVALUE is present, set the timeout value (in milliseconds) used for DDE operations; return the old value.

    The timeout value is initially set to $Win32::DDE::Client::Timeout when the object is constructed. $Win32::DDE::Client::Timeout is set to 1000 when the module is loaded.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: $SIG{ALRM} timeout and Win32::DDE::Client hangs?
by erroneousBollock (Curate) on Nov 06, 2007 at 01:00 UTC
    Signals (in perl) are a hack on Win32, you can't expect them to be delivered to (and understood by) non-perl Win32 software like the "ZP4" application (whatever that is).

    -David

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://649115]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-23 18:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found