root/misc/memcheck

Revision 2948 (checked in by miyagawa, 10 years ago)

use env perl

  • Property svn:executable set to *
Line 
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4
5 my $proc = shift;
6 my $mem  = shift or die "Usage: memcheck process memory signal";
7 my $sig  = shift || 2;
8    $sig =~ s/^-//;
9
10 my @lines = qx(ps auxww | grep $proc | grep -v grep | grep -v memcheck);
11 unless (@lines) { exit }
12
13 my($pid, $memory) = (split /\s+/, $lines[0])[1,4];
14 if ($memory > $mem) {
15     warn "killing $pid since $proc memory usage is $memory (> $mem)";
16     kill $sig, $pid or die $!;
17 }
Note: See TracBrowser for help on using the browser.