in reply to fork and exec a codeblock
Update: s/MainLoop/Tk::MainLoop()/package MeMz; use warnings; use strict; use vars qw(@ISA @EXPORT_OK); @ISA = qw(Exporter); # inherit the import() from Exporter.pm @EXPORT_OK = qw(); # list of things to export if asked to if (fork() == 0) { require Tk; my $mw = new MainWindow; $mw->overrideredirect(1); my $t = $mw->Label(-text => '', -bg => 'black', -fg => 'yellow')-> +pack; my $id = Tk::After->new($mw, 1000, 'repeat', [ \&refresh, $pid ]); Tk::MainLoop(); sub refresh { my $pid = shift; my @size = split "\n", `cat /proc/$pid/status`; (my $vmsize) = grep { /VmSize/ } @size; my (undef, $size) = split ' ', $vmsize; $t->configure(-text => "PID: $pid -> $size"); if ($size eq '') { Tk::exit } } } 1;
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: fork and exec a codeblock
by Anomynous Monk (Scribe) on Mar 16, 2004 at 19:38 UTC | |
by Aristotle (Chancellor) on Mar 16, 2004 at 19:45 UTC |