Looks correct to me... Apologies to everyone if it isn't :P I applied it
and it's going into 1.4.8.

thanks!

On Thu, 29 Sep 2011, Nate wrote:

> At some point it looks like start-memcached was changed to fork an
> extra time, as the comments put it, "now that the tty is closed."  I'm
> not sure why, but what I noticed is that the wrong PID was being
> written to the PID file.  It was writing the PID of the intermediate
> fork, not the one of the child that was getting replaced by the exec.
> So I just moved the code that writes the PID to the child of the first
> fork and it's working for me again.  With this fix the init script can
> stop the server that it had started.  Here's a patch for that very
> simple fix.
>
> Thanks,
> Nathan Shafer
>
> --- start-memcached.orig      2011-09-29 11:19:42.000000000 -0700
> +++ start-memcached   2011-09-29 11:23:15.000000000 -0700
> @@ -112,18 +112,17 @@
>      # must fork again now that tty is closed
>      $pid = fork();
>      if ($pid) {
> +      if(open PIDHANDLE,">$pidfile")
> +      {
> +          print PIDHANDLE $pid;
> +          close PIDHANDLE;
> +      }else{
> +
> +          print STDERR "Can't write pidfile to $pidfile.\n";
> +      }
>        exit(0);
>      }
>      exec "$memcached $params";
>      exit(0);
>
> -}else{
> -    if(open PIDHANDLE,">$pidfile")
> -    {
> -        print PIDHANDLE $pid;
> -        close PIDHANDLE;
> -    }else{
> -
> -        print STDERR "Can't write pidfile to $pidfile.\n";
> -    }
>  }
>

Reply via email to