Browse Source

Fix while trying to find pids for a screen session that was closed.

This fix avoids the error 'undefined $pid value'.
DieFeM 8 years ago
parent
commit
985853e3e9
1 changed files with 7 additions and 4 deletions
  1. 7 4
      ogp_agent.pl

+ 7 - 4
ogp_agent.pl

@@ -449,12 +449,15 @@ sub get_home_pids
 	my $screen_id = create_screen_id(SCREEN_TYPE_HOME, $home_id);
 	my ($pid, @pids);
 	($pid) = split(/\./, `screen -ls | grep -E -o "[0-9]+\.$screen_id"`, 2);
-	chomp($pid);
-	while ($pid =~ /^[0-9]+$/)
+	if(defined $pid)
 	{
-		push(@pids,$pid);
-		$pid = `pgrep -P $pid`;
 		chomp($pid);
+		while ($pid =~ /^[0-9]+$/)
+		{
+			push(@pids,$pid);
+			$pid = `pgrep -P $pid`;
+			chomp($pid);
+		}
 	}
 	return @pids;
 }