Subject: | Bug report for Win32::API::Callback |
Date: | Fri, 22 Jan 2010 13:24:21 +0200 |
To: | bug-Win32-API [...] rt.cpan.org |
From: | perlsite [...] mail.bg |
Hello,
The code below generate exception and application dies with the
following "Error signature"
AppName: perl.exe AppVer: 5.10.0.1004 ModName: perl510.dll
ModVer: 5.10.0.1004 Offset: 000961d5
# --- code start ---
#!/usr/bin/perl
use strict;
use Win32::API;
use Win32::API::Callback;
Win32::API->Import('kernel32', 'SetConsoleCtrlHandler', 'KL', 'L');
Win32::API->Import('kernel32', 'GenerateConsoleCtrlEvent', 'LL', 'L');
Win32::API->Import('kernel32', 'GetLastError', '', 'L');
sub cb {
my ($dwCtrlType) = @_;
open (FILE, '>c:/QUIT.TXT');
print FILE "RECEIVED SIGNAL: $dwCtrlType\n";
close FILE;
return 0;
}
my $callback = Win32::API::Callback->new(\&cb, "L", "L");
SetConsoleCtrlHandler($callback, 1) or die "Error: " . GetLastError() . "\n";
sleep(1);
GenerateConsoleCtrlEvent(0, 0);
sleep(2);
# --- code end ---
The error occurs when cb() routine is called, no matter whether it is
triggered through GenerateConsoleCtrlEvent call or via while(1){} and
Ctrl+C. Also specific implementation of cb() routine doesn't matter,
i.e. callback body can be just return 0 or return 1 - same effect (in
my implementation no file is created, so I assume that exception is
generated when OS try to call the callback). My personal opinion is
that $callback handler is not properly implemented.
My test fails both with Win32-API version 0.55 and 0.58 (ActiveState build).
I'm using Windows XP Professional, SP3 (up-to-date installation).
Regards,
Julian
-------------------------------------
Хостинг от 3.60 лв/м| Домейни от 17.46 лв/с ДДС| Сървъри, VPS от 48.00
лв/м с ДДС!
18 GB място, Неограничен трафик, Безплатен домейн – 6.90 лв./м с ДДС!
25 GB място, 1200 GB трафик, Безплатен домейн – 11.46 лв./м с ДДС!