Browse Source

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
Guillem Jover 11 years ago
parent
commit
f7b328a12c
2 changed files with 7 additions and 0 deletions
  1. 4 0
      debian/changelog
  2. 3 0
      utils/start-stop-daemon.c

+ 4 - 0
debian/changelog

@@ -3,6 +3,10 @@ dpkg (1.17.19) UNRELEASED; urgency=low
   [ Guillem Jover ]
   [ Guillem Jover ]
   * Bump the Breaks on devscripts to 2.14.10 due to the new dpkg-architecture
   * Bump the Breaks on devscripts to 2.14.10 due to the new dpkg-architecture
     command-line parsing strictness introduced in 1.17.17. Closes: #764965
     command-line parsing strictness introduced in 1.17.17. Closes: #764965
+  * Create pidfiles even when start-stop-daemon is not asked to background
+    the process itself. Although a bit of a dubious usage, because any error
+    before executing the program will not be properly reported to the caller.
+    Regression introduced in dpkg 1.17.14. Closes: #765110
 
 
   [ Updated programs translations ]
   [ Updated programs translations ]
   * Turkish (Mert Dirik). Closes: #764942
   * Turkish (Mert Dirik). Closes: #764942

+ 3 - 0
utils/start-stop-daemon.c

@@ -1843,6 +1843,9 @@ do_start(int argc, char **argv)
 	if (background)
 	if (background)
 		/* Ok, we need to detach this process. */
 		/* Ok, we need to detach this process. */
 		daemonize();
 		daemonize();
+	else if (mpidfile && pidfile != NULL)
+		/* User wants _us_ to make the pidfile, but detach themself! */
+		write_pidfile(pidfile, getpid());
 	if (background && close_io) {
 	if (background && close_io) {
 		devnull_fd = open("/dev/null", O_RDWR);
 		devnull_fd = open("/dev/null", O_RDWR);
 		if (devnull_fd < 0)
 		if (devnull_fd < 0)