bae11208 has asked for the wisdom of the Perl Monks concerning the following question:
Problem is that i get zombies..... The main Program must run because it runs as a daemon so i can't exit it to cleanup my zombie prozesses........ ps aux |grep Z USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 307 0.0 0.0 0 0 pts/1 Z+ 19:27 0:00 a2.pl <defunct> root 319 0.0 0.0 0 0 pts/1 Z+ 19:27 0:00 a2.pl <defunct> root 324 0.0 0.0 0 0 pts/1 Z+ 19:28 0:00 a2.pl <defunct> root 334 0.0 0.0 0 0 pts/1 Z+ 19:28 0:00 a2.pl <defunct> root 353 0.1 0.0 0 0 pts/1 Z+ 19:28 0:00 a2.pl <defunct> root 381 0.0 0.0 0 0 pts/1 Z+ 19:28 0:00 a2.pl <defunct> root 404 0.2 0.0 0 0 pts/1 Z+ 19:28 0:00 a2.pl <defunct> root 421 0.0 0.0 9852 872 pts/2 S+ 19:28 0:00 grep Z
Main Perl String #!/usr/bin/perl -w use strict; use warnings; use IPC::Cmd qw[can_run run run_forked]; my $timeout = 1; my $erg; my $cmd='/home/a2.pl'; while(1){ if( scalar run( command => $cmd, verbose => 0, buffer => \$erg +, timeout => $timeout )){ print 'success:'.$erg."\n"; }else{ if(!$erg){ $erg='ERROR'; } print 'timeout cmd:'.$cmd.' ergr='.$erg."\n"; } sleep(5); } 1; /home/a2.pl #!/usr/bin/perl print 10000; #print 'or some text.....'; 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Function for Timing out shell commands without getting Zombie Prozesses
by zentara (Cardinal) on Sep 15, 2011 at 18:46 UTC | |
|
Re: Function for Timing out shell commands without getting Zombie Prozesses
by BrowserUk (Patriarch) on Sep 15, 2011 at 17:44 UTC | |
by Anonymous Monk on Sep 15, 2011 at 18:53 UTC | |
by bae11208 (Initiate) on Sep 15, 2011 at 18:54 UTC | |
by BrowserUk (Patriarch) on Sep 15, 2011 at 19:03 UTC | |
|
Re: Function for Timing out shell commands without getting Zombie Prozesses
by eyepopslikeamosquito (Archbishop) on Sep 16, 2011 at 02:16 UTC |