Glib::IO->add_watch and log files
- From: Daniel Kasak <dkasak nusconsulting com au>
- To: gtk-perl-list gnome org
- Subject: Glib::IO->add_watch and log files
- Date: Tue, 20 Mar 2007 13:50:17 +1100
Hi all.
I'm starting up an application and redirecting STDOUT with:
open STDOUT, '>', "$self->{globals}->{appdir}/app.log" or die "Can't
redirect STDOUT: $!";
$| = 1;
Then later on I'm using some code I found on the list from a while back
( modified a bit ... I suppose I broke it ... ):
my $buffer = $self->{form}->get_widget( "AppLog_TextView" )->get_buffer;
open LOGFILE, "<", "$self->{globals}->{appdir}/app.log";
$| = 1;
Glib::IO->add_watch ( fileno(LOGFILE), ['in', 'hup'], sub {
my ($fileno, $condition) = @_;
if ($condition eq 'hup') {
warn "done\n";
close LOGFILE;
return 0; # uninstall
}
my $line;
sysread LOGFILE, $line, 1024;
$buffer->insert($buffer->get_end_iter, $line);
return 1;
});
When this runs, the above subs keeps getting called ( apparently without
reading anything ... if I warn $line I get nothing ), and my app never
gets any further! What have I done?
--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
website: http://www.nusconsulting.com.au
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]