1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00

libdaemon-server: Do not create pidfile if NULL.

This commit is contained in:
Petr Rockai 2012-10-09 20:22:30 +02:00
parent ff752c60df
commit 329d10268c

View File

@ -466,16 +466,18 @@ void daemon_start(daemon_state s)
daemon_log_enable(s.log, DAEMON_LOG_OUTLET_SYSLOG, DAEMON_LOG_FATAL, 1);
daemon_log_enable(s.log, DAEMON_LOG_OUTLET_SYSLOG, DAEMON_LOG_ERROR, 1);
(void) dm_prepare_selinux_context(s.pidfile, S_IFREG);
if (s.pidfile) {
(void) dm_prepare_selinux_context(s.pidfile, S_IFREG);
/*
* NB. Take care to not keep stale locks around. Best not exit(...)
* after this point.
*/
if (dm_create_lockfile(s.pidfile) == 0)
exit(1);
/*
* NB. Take care to not keep stale locks around. Best not exit(...)
* after this point.
*/
if (dm_create_lockfile(s.pidfile) == 0)
exit(1);
(void) dm_prepare_selinux_context(NULL, 0);
(void) dm_prepare_selinux_context(NULL, 0);
}
/* Set normal exit signals to request shutdown instead of dying. */
signal(SIGINT, &_exit_handler);
@ -526,7 +528,8 @@ void daemon_start(daemon_state s)
INFO(&s, "%s shutting down", s.name);
closelog(); /* FIXME */
remove_lockfile(s.pidfile);
if (s.pidfile)
remove_lockfile(s.pidfile);
if (failed)
exit(1);
}