Skip Menu |

This queue is for tickets about the Win32-IPC CPAN distribution.

Report information
The Basics
Id: 73747
Status: stalled
Priority: 0/
Queue: Win32-IPC

People
Owner: Nobody in particular
Requestors: cary.lewis [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: question / possible bug with Win32::IPC
Date: Wed, 4 Jan 2012 14:14:37 -0500
To: bug-Win32-IPC [...] rt.cpan.org
From: Cary Lewis <cary.lewis [...] gmail.com>
I am using Win::IPC via Win::ChangeNotify, and I have noticed that if I have a signal handler active at the time of doing a wait, then the signal that is being "handled" is ignored. The following code demonstrates the issue: use Win32::ChangeNotify; $WatchSubTree = 0; $Events="FILE_NAME"; $notify = Win32::ChangeNotify->new(".", $WatchSubTree, $Events); $SIG{INT} = sub {print "ok\n";exit;}; print "during this sleep, intr will be caught!\n"; sleep(2); while(1) { print "waiting\n"; $notify->wait(); print "change!\n"; $notify->reset; } Once the $notify->wait() call is executed, the $SIG{INT} no longer works, and furthermore, hitting ctrl-c no longer interrupts the wait. Without the $SIG{INT} code, ctrl-c does interrupt the wait. I tried to search for Win32::IPC wait and signal handler - but didn't see anything relevant, so I hope you don't mind me sending you an email. BTW, I running this on Windows 7 32bit under Cygwin and I also reproduced this with the strawberry perl. Any insight would be most appreciated.
Subject: signal handlers don't work while waiting
The behavior I see with Windows XP and Perl 5.14.2 is this: if a signal handler is active, it's not called until the wait completes (because a notification happens or it times out). I'm not clear whether you're seeing the same thing. I believe this is because of Perl's deferred signal handling: http://perldoc.perl.org/perlipc.html#Deferred-Signals-%28Safe-Signals%29 I agree that's probably not the most desirable behavior, but I don't know how to change it. I'd welcome a pull request (https://github.com/madsen/win32-ipc) if you have a solution.
Subject: Re: [rt.cpan.org #73747] signal handlers don't work while waiting
Date: Fri, 6 Jan 2012 23:51:24 -0500
To: bug-Win32-IPC [...] rt.cpan.org
From: Cary Lewis <cary.lewis [...] gmail.com>
I've tried everything I could think of, but was not successful in getting the signal handler to work while perl was sitting inside the WaitForSingleObject, inside of ipc code. However, I was able to work around the issue by utilizing threads - if I spin up a perl thread and do the change notify in it, and detach this thread from the main thread, both the change notify blocking functionality works, and the signal handler works. I can use condition variables to signal the change in the directory to the main thread. So, this isn't really a fix, just a workaround, but I wonder where I can post this little titbit of knowledge. On Wed, Jan 4, 2012 at 4:54 PM, Christopher J. Madsen via RT < bug-Win32-IPC@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=73747 > > > The behavior I see with Windows XP and Perl 5.14.2 is this: if a signal > handler is active, it's not called until the wait completes (because a > notification happens or it times out). I'm not clear whether you're > seeing the same thing. > > I believe this is because of Perl's deferred signal handling: > http://perldoc.perl.org/perlipc.html#Deferred-Signals-%28Safe-Signals%29 > > I agree that's probably not the most desirable behavior, but I don't > know how to change it. I'd welcome a pull request > (https://github.com/madsen/win32-ipc) if you have a solution. >
On Fri, Jan 6, 2012 10:51:32 PM, cary.lewis@gmail.com wrote: Show quoted text
> So, this isn't really a fix, just a workaround, but I wonder where I can > post this little titbit of knowledge.
I'll put a note in the documentation for the next release. If you have anything you'd like me to include, you can post it here or send a pull request.