Skip to content

Commit

Permalink
If a daemon dies (or exits), it can leave an unwaited for zombie
Browse files Browse the repository at this point in the history
which pid_exists() still believes is running, the result is that
ubic-guardian keeps looping around in the can_read loop and never
restarts the dead process.
  • Loading branch information
divereigh committed Apr 22, 2019
1 parent c190e51 commit e501ba8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Ubic/Daemon/OS/Linux.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ use parent qw(Ubic::Daemon::OS);
sub pid2guid {
my ($self, $pid) = @_;

unless (-d "/proc/$pid") {
unless ($self->pid_exists($pid)) {
return; # process not found
}
my $opened = open(my $fh, '<', "/proc/$pid/stat");
unless ($opened) {
# open failed
my $error = $!;
unless (-d "/proc/$pid") {
unless ($self->pid_exists($pid)) {
return; # process exited right now
}
die "Open /proc/$pid/stat failed: $!";
Expand Down Expand Up @@ -78,7 +78,7 @@ sub close_all_fh {

sub pid_exists {
my ($self, $pid) = @_;
return (-d "/proc/$pid");
return (-d "/proc/$pid" && -e "/proc/$pid/exe");
}

1;

0 comments on commit e501ba8

Please sign in to comment.