From bf1e9952e1e4bad55420ba6f11a50c3b8fff9fca Mon Sep 17 00:00:00 2001 From: Zdenek Styblik Date: Tue, 24 Jan 2012 13:59:58 +0000 Subject: [PATCH] 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. --- ipmitool/src/ipmievd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ipmitool/src/ipmievd.c b/ipmitool/src/ipmievd.c index f5a2613..bf1c3ae 100644 --- a/ipmitool/src/ipmievd.c +++ b/ipmitool/src/ipmievd.c @@ -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) {