From: Jakub Narebski Date: Tue, 09 Feb 2010 22:23:17 GMT Subject: Re: [RFC PATCHv2 09/10] gitweb/cache.pm - Regenerate (refresh) cache in background Message-ID: <201002092323.24832.jnareb@gmail.com> In-Reply-To: <1265711427-15193-10-git-send-email-jnareb@gmail.com> On Tue, 9 Feb 2010, Jakub Narebski wrote: [...] > +               my $pid = fork() if ($data && $self->get_background_cache()); > +               if (!defined $pid || $pid) { > +                       # parent, or didn't fork > +                       $data = $p_coderef->($self, $p_key); > +                       $self->set($p_key, $data); > + > +                       if ($pid) { > +                               # releases lock before waiting and exiting > +                               close $lock_fh; > +                               # wait for child (which would print) and exit > +                               waitpid $pid, 0; > +                               exit 0; > +                       } > +               } else { > +                       # child is to serve stale data > +                       return $data; > +               } [...] I have decide to rely on $SIG{CHLD} = 'IGNORE' to not generate zombies, and consistently exit in child (in forked process) and return in parent. This change would be in next version of this series. -- Jakub Narebski Poland