Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Don't die when you HUP gmond -p #29

Merged
merged 1 commit into from

3 participants

@shufgy

If you HUP gmond and you ran it with -p it will reexec itself, keeping its
pid, read the pidfile, find a process with its pid running and exit (so as
to prevent two gmonds running at once). This isn't correct as it should
just keep running and not do anything with its pidfile.

@shufgy shufgy Don't mess with pidfile if it has our pid
If you HUP gmond and you ran it with -p it will reexec itself, keeping its
pid, read the pidfile, find a process with its pid running and exit (so as
to prevent two gmonds running at once).  This isn't correct as it should
just keep running and not do anything with its pidfile.
e1d67db
@dpocock

what if the file is stale (e.g. a previous process crashed and left it intact) and some other process is running with that PID?

That can't be true.
If getpid() returns the pid in the file, we are that pid.

It's been ages since I looked at this patch though and I can't remember if we're still running with it in production. I have a feeling we just turned off pidfiles all together as something else stopped HUPing working.

@vvuksan vvuksan merged commit 3a73991 into ganglia:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 29, 2012
  1. @shufgy

    Don't mess with pidfile if it has our pid

    shufgy authored
    If you HUP gmond and you ran it with -p it will reexec itself, keeping its
    pid, read the pidfile, find a process with its pid running and exit (so as
    to prevent two gmonds running at once).  This isn't correct as it should
    just keep running and not do anything with its pidfile.
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/update_pidfile.c
View
12 lib/update_pidfile.c
@@ -31,8 +31,16 @@ update_pidfile (char *pidfile)
if (fscanf(file, "%ld", &p) == 1 && (pid = p) &&
(getpgid (pid) > -1))
{
- err_msg("daemon already running: %s pid %ld\n", pidfile, p);
- exit (1);
+ if (pid != getpid())
+ {
+ err_msg("daemon already running: %s pid %ld\n", pidfile, p);
+ exit (1);
+ }
+ else
+ {
+ /* We have the same PID so were probably HUP'd */
+ return;
+ }
}
fclose (file);
}
Something went wrong with that request. Please try again.