Re: The "Right Way" (TM) to run external program out of gtk2-perl app?
- From: "A. Pagaltzis" <pagaltzis gmx de>
- To: gtk-perl-list gnome org
- Subject: Re: The "Right Way" (TM) to run external program out of gtk2-perl app?
- Date: Tue, 30 Aug 2005 19:38:22 +0200
* muppet <scott asofyet org> [2005-08-30 17:25]:
sub run_convert {
my $convert_command = shift;
my $main_loop = Glib::MainLoop->new;
my $pid = open CHILD, "$convert_command |"
or die "can't fork convert: $!";
Glib::IO->add_watch (fileno CHILD, ['hup'], sub {
$main_loop->quit;
FALSE;
});
$main_loop->run;
close CHILD or warn "convert died with exit status ".($? >> 8)."\n";
}
Of course it would still be better if muppet could get into the
habit of using three-argument open() with lexical filehandles.
:-)
sub run_convert {
my @cmd = @_;
my $main_loop = Glib::MainLoop->new;
my $pid = open my $child, '-|', @cmd
or die "can't fork convert: $!";
Glib::IO->add_watch (fileno $child, ['hup'], sub {
$main_loop->quit;
FALSE;
});
$main_loop->run;
close $child or warn "convert died with exit status ".($? >> 8)."\n";
}
Pedantically promoting better Perl practices since ought one,
--
#Aristotle
*AUTOLOAD=*_=sub{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]