#!/usr/bin/perl -w

use strict;

chdir ("/proc");

my $zombies = 0;

foreach my $pid (glob ("[1-9]*")) {
	open F, "$pid/status" or next;
	while (<F>) {
		if (/^State:\s+Z/) {
			my $mtime = (stat ($pid))[9];
			last if not defined $mtime or time - $mtime < 60;
			system "ps u $pid";
			$zombies++;
			last;
		}
	}
	close F;
}

if ($zombies) {
	exit 1;
} else {
	print "No zombie processes\n";
	exit 0;
}
