You can click the GMeM window to kill it.
UPDATE May-8-2005 With another thanks to muppet, for pointing it out, I changed "use Gtk2 -init" to "eval use Gtk2 -init". This prevents the calling program from unnecesarily loading Gtk2 modules, if it is not Gtk2 based ( i.e. a commandline program or a Tk app).
package GMeM; use warnings; use strict; #save this file as GMeM.pm and place in your PERL5LIB my $pid =$$; #gets the caller script's pid and #passes it thru the fork-&-exec below #only gets created after fork and exec to prevent #module's X socket connection from interfering with #calling program's X socket connection if ((defined $ARGV[0]) and ($ARGV[0] eq 'GMeM')) { #use Gtk2 '-init'; #BAD unnecessarily loads modules eval "use Gtk2 -init;"; $pid = $ARGV[1]; my $blueh = Gtk2::Gdk::Color->new (0,0xFFFF,0xFFFF); my $bluel = Gtk2::Gdk::Color->new (0,0xCCCC,0xFFFF); Gtk2::Rc->parse_string(<<___EOS); style "normal" { font_name ="Sans Bold 12" } widget "*" style "normal" ___EOS my $win = Gtk2::Window->new('popup'); $win->signal_connect( 'destroy' => \&delete_event ); my ($xscr, $yscr) = (Gtk2::Gdk->screen_width, Gtk2::Gdk->screen_he +ight); $win->move($xscr - 180, $yscr - 20); my $but = Gtk2::Button->new("PID: $pid-> " ); $but->modify_bg ('normal', $blueh); $but->modify_bg ('prelight', $bluel); $but->signal_connect( 'clicked' => \&delete_event ); $win->add($but); $0 = "GMeM $pid"; $win->show_all(); &refresh($pid); my $repeater = Glib::Timeout->add(1000, sub{ refresh($pid) ; 1;} ) +; Gtk2->main; ##################################### sub delete_event { Gtk2->main_quit; return 0; } sub refresh { my $pid = shift; #asmutils version of cat #my @size = split "\n", `/home/zentara/perl5lib/cat /proc/$pid +/status`; my @size = split "\n", `cat /proc/$pid/status`; (my $vmsize) = grep { /VmSize/ } @size; my (undef, $size) = split ' ', $vmsize; $but->set_label("PID: $pid -> $size"); if ($size eq '') { exit } } #################################### } elsif (fork() == 0) { exec "$^X -MGMeM -e1 GMeM $pid"; } # thanks to muppet for this cleverness 1;
|
|---|