Bugfix : Sometimes proccess are stopped between readir of /proc and analyze. This should not raise an error

This commit is contained in:
Grégory Soutadé 2021-11-26 08:19:41 +01:00
parent 4973e18ea1
commit 449cf97d71

View File

@ -182,7 +182,7 @@ while (my $pid = readdir(DIR)) {
# Get owner name
my $uid = 0;
open(FIC,"</proc/$pid/status") or die $!;
open(FIC,"</proc/$pid/status") or next; # Processus may have stopped between readdir and analyze
while( defined( $l = <FIC> ) ) {
if ($l =~ /Uid:\s+([0-9]+)\s+.*/)
{
@ -196,7 +196,7 @@ while (my $pid = readdir(DIR)) {
$quota,$comment,$gcos,$dir,$shell,$expire) = getpwuid($uid);
# Get infos
open(FIC,"</proc/$pid/stat") or die $!;
open(FIC,"</proc/$pid/stat") or next; # Processus may have stopped between readdir and analyze
my @infos = split(/ /, <FIC>);
close (FIC);