]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdmon: suicide prevention
authorDan Williams <dan.j.williams@intel.com>
Fri, 3 Oct 2008 05:26:00 +0000 (22:26 -0700)
committerDan Williams <dan.j.williams@intel.com>
Wed, 15 Oct 2008 21:43:57 +0000 (14:43 -0700)
mdmon cannot remove the pidfile at shutdown becuase it needs to stay
running across the "mount -o remount,ro /" event.  When it relaunches
after a reboot there is a good chance that the pid will match what was
there previously.  The result is that the "take over for unresponsive
mdmon" logic results in self termination.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
mdmon.c

diff --git a/mdmon.c b/mdmon.c
index d6b99a21c9c19471337bda64f32ca84d25a95912..32805a84efe1abe21baed8a8cb489dcdcc21e765 100644 (file)
--- a/mdmon.c
+++ b/mdmon.c
@@ -139,6 +139,10 @@ static void try_kill_monitor(char *devname)
        close(fd);
        pid = strtoul(buf, NULL, 10);
 
+       /* first rule of survival... don't off yourself */
+       if (pid == getpid())
+               return;
+
        /* kill this process if it is mdmon */
        sprintf(buf, "/proc/%lu/cmdline", (unsigned long) pid);
        fd = open(buf, O_RDONLY);