aboutsummaryrefslogtreecommitdiff
path: root/sbin/hastd
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2012-01-10 22:24:57 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2012-01-10 22:24:57 +0000
commit45bd093cb0b87c730cae5adf4e2878a4f3b678cf (patch)
treefb0a77e3497b4f319b1bfbdd5779002316fb865e /sbin/hastd
parentbd4df56c713a84e93d433ac150ca68bc650f9760 (diff)
downloadsrc-45bd093cb0b87c730cae5adf4e2878a4f3b678cf.tar.gz
src-45bd093cb0b87c730cae5adf4e2878a4f3b678cf.zip
Don't touch pidfiles when running in foreground. Before that change we
would create an empty pidfile on start and check if it changed on SIGHUP. MFC after: 3 days
Notes
Notes: svn path=/head/; revision=229944
Diffstat (limited to 'sbin/hastd')
-rw-r--r--sbin/hastd/hastd.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/sbin/hastd/hastd.c b/sbin/hastd/hastd.c
index e2f1f8c6cb53..bea390a6a664 100644
--- a/sbin/hastd/hastd.c
+++ b/sbin/hastd/hastd.c
@@ -68,6 +68,8 @@ static struct hastd_config *cfg;
bool sigexit_received = false;
/* PID file handle. */
struct pidfh *pfh;
+/* Do we run in foreground? */
+static bool foreground;
/* How often check for hooks running for too long. */
#define REPORT_INTERVAL 5
@@ -531,7 +533,7 @@ hastd_reload(void)
/*
* Check if pidfile's path has changed.
*/
- if (strcmp(cfg->hc_pidfile, newcfg->hc_pidfile) != 0) {
+ if (!foreground && strcmp(cfg->hc_pidfile, newcfg->hc_pidfile) != 0) {
newpfh = pidfile_open(newcfg->hc_pidfile, 0600, &otherpid);
if (newpfh == NULL) {
if (errno == EEXIST) {
@@ -1155,7 +1157,6 @@ main(int argc, char *argv[])
struct hastd_listen *lst;
const char *pidfile;
pid_t otherpid;
- bool foreground;
int debuglevel;
sigset_t mask;
@@ -1220,16 +1221,23 @@ main(int argc, char *argv[])
pjdlog_exitx(EX_CONFIG, "Pidfile path is too long.");
}
}
- pfh = pidfile_open(cfg->hc_pidfile, 0600, &otherpid);
- if (pfh == NULL) {
- if (errno == EEXIST) {
- pjdlog_exitx(EX_TEMPFAIL,
- "Another hastd is already running, pidfile: %s, pid: %jd.",
- cfg->hc_pidfile, (intmax_t)otherpid);
+
+ if (!foreground) {
+ pfh = pidfile_open(cfg->hc_pidfile, 0600, &otherpid);
+ if (pfh == NULL) {
+ if (errno == EEXIST) {
+ pjdlog_exitx(EX_TEMPFAIL,
+ "Another hastd is already running, pidfile: %s, pid: %jd.",
+ cfg->hc_pidfile, (intmax_t)otherpid);
+ }
+ /*
+ * If we cannot create pidfile for other reasons,
+ * only warn.
+ */
+ pjdlog_errno(LOG_WARNING,
+ "Unable to open or create pidfile %s",
+ cfg->hc_pidfile);
}
- /* If we cannot create pidfile for other reasons, only warn. */
- pjdlog_errno(LOG_WARNING, "Unable to open or create pidfile %s",
- cfg->hc_pidfile);
}
/*