summaryrefslogtreecommitdiff
path: root/utils/start-stop-daemon.c
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2014-10-13 21:03:14 +0200
committerGuillem Jover <guillem@debian.org>2014-10-16 21:21:42 +0200
commitf7b328a12c21ed6d4d0bdc17bc45fb4545165bb3 (patch)
treec9c6f15455d06681067dcf9ed20f7e92122747e0 /utils/start-stop-daemon.c
parent1bc921f8c8bcad83158cd240da4ecb266d9dc62f (diff)
downloaddpkg-f7b328a12c21ed6d4d0bdc17bc45fb4545165bb3.tar.gz
s-s-d: Create a pidfile even when not backgrounding ourselves
Regression introduced in commit 29778da537e2ff1a0f032db33dde43413b7345ef. When the user asked us to create the pidfile, but _not_ to background ourselves, we should still create the pidfile. This usage is somewhat dubious, as s-s-d has an option to background, which is better in any way, as it will make sure to return error codes in case the program cannot be started for whatever reason. But it's still a regression. Closes: #765110
Diffstat (limited to 'utils/start-stop-daemon.c')
-rw-r--r--utils/start-stop-daemon.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index 3411dfdec..abead7fa0 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -1843,6 +1843,9 @@ do_start(int argc, char **argv)
if (background)
/* Ok, we need to detach this process. */
daemonize();
+ else if (mpidfile && pidfile != NULL)
+ /* User wants _us_ to make the pidfile, but detach themself! */
+ write_pidfile(pidfile, getpid());
if (background && close_io) {
devnull_fd = open("/dev/null", O_RDWR);
if (devnull_fd < 0)