Fixes ignorance of existing PID file which results in PID being overwritten.

Start of the daemon has shifted couple lines bellow, because it doesn't make
sense to start daemon first and check existence of PID file later.
This commit is contained in:
Zdenek Styblik 2012-01-24 13:59:58 +00:00
parent 5ed7f6ac0a
commit bf1e9952e1

View File

@ -737,15 +737,15 @@ ipmievd_main(struct ipmi_event_intf * eintf, int argc, char ** argv)
FILE *fp;
struct stat st1;
ipmi_start_daemon(eintf->intf);
if (lstat(pidfile, &st1) == 0) {
/* already exists, erase first */
if (unlink(pidfile) != 0) {
lprintf(LOG_WARN, "Unable to erase pidfile");
}
/* PID file already exists -> exit. */
lprintf(LOG_ERR, "PID file '%s' already exists.\n", pidfile);
lprintf(LOG_ERR, "Perhaps another instance is already running.\n");
return (-1);
}
ipmi_start_daemon(eintf->intf);
umask(022);
fp = ipmi_open_file_write(pidfile);
if (fp != NULL) {