mdmon: suicide prevention

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>
This commit is contained in:
Dan Williams 2008-10-02 22:26:00 -07:00
parent 27dec8fae3
commit 8aae4219a2
1 changed files with 4 additions and 0 deletions

View File

@ -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);