aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-31 01:24:44 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-31 01:24:44 +0100
commitf83a5c48b5df25fe92e3b013f9e292d1b52e215f (patch)
tree0f1a576e0c30923d41f4507947edf521ecf59258 /src
parentdaemonise: add option to override pid file (diff)
downloadslibc-f83a5c48b5df25fe92e3b013f9e292d1b52e215f.tar.gz
slibc-f83a5c48b5df25fe92e3b013f9e292d1b52e215f.tar.bz2
slibc-f83a5c48b5df25fe92e3b013f9e292d1b52e215f.tar.xz
m
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src')
-rw-r--r--src/unistd/daemonise.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/unistd/daemonise.c b/src/unistd/daemonise.c
index 9df70da..e7ae471 100644
--- a/src/unistd/daemonise.c
+++ b/src/unistd/daemonise.c
@@ -177,8 +177,9 @@ static int dup_at_least_3(int old)
* has exited without removing the PID file.
* @throws EINVAL `flags` contains an unsupported bit, both
* `DAEMONISE_KEEP_STDERR` and `DAEMONISE_CLOSE_STDERR`
- * are set, or both `DAEMONISE_CLOSE_STDERR` and
- * `DAEMONISE_KEEP_FDS` are set whilst `2` is
+ * are set, both `DAEMONISE_NO_PID_FILE` and
+ * `DAEMONISE_NEW_PID`, or both `DAEMONISE_CLOSE_STDERR`
+ * and `DAEMONISE_KEEP_FDS` are set whilst `2` is
* in the list of file descriptor not to close.
* @throws Any error specified for signal(3).
* @throws Any error specified for sigemptyset(3).
@@ -215,9 +216,10 @@ int daemonise(const char* name, int flags, ...)
/* Validate flags. */
if (flags & (int)~(2048L * 2 - 1))
return errno = EINVAL, -1;
- if (flags & DAEMONISE_KEEP_STDERR)
- if (flags & DAEMONISE_CLOSE_STDERR)
- return errno = EINVAL, -1;
+ if ((flags & DAEMONISE_KEEP_STDERR) && (flags & DAEMONISE_CLOSE_STDERR))
+ return errno = EINVAL, -1;
+ if ((flags & DAEMONISE_NO_PID_FILE) && (flags & DAEMONISE_NEW_PID))
+ return errno = EINVAL, -1;
/* Find out which file descriptors not too close. */