Subject: | listen returns in thread. |
Date: | Wed, 07 Oct 2009 21:54:31 -0600 |
To: | bug-Mac-SleepEvent [...] rt.cpan.org |
From: | TDH <bitcard [...] smoky.tikasys.com> |
When I use Mac::SleepEvent in a multithreaded program if fails for
reason I don't understand.
Mac OS X 10.6.1
Mac::SleepEvent 0.02,
Consider the following script, listen returns with $! set to "No such
file or directory". Maybe I'm trying something that was not intended...
#!/usr/bin/perl
use strict;
use threads;
use Mac::SleepEvent;
my $thr = threads->create(\&monitor_thread);
$thr->detach();
sleep 120;
sub monitor_thread {
my $sn = Mac::SleepEvent->new(
wake => sub {warn "waking\n"},
sleep => sub {warn "sleeping\n"},
logout => sub {warn "logging off\n"},
);
$sn->listen;
warn "monitor thread died: $!\n";
exit(0);
}