busybox: remove pid file after stopping daemon with start-stop-daemon applet

Submitted by Stefan Fröberg on Feb. 21, 2013, 7:12 p.m.

Details

Message ID 1361473963-5943-1-git-send-email-stefan.froberg@petroprogram.com
State Rejected
Headers show

Commit Message

Stefan Fröberg Feb. 21, 2013, 7:12 p.m.
Many daemons leave pid files lying around when they are stopped with
start-stop-daemon applet in BusyBox.
This patch will ensure that they are properly cleaned away.

Signed-off-by: Stefan Fröberg <stefan.froberg@petroprogram.com>
---

Note: I did not make this patch but found it from old thread in BusyBox
mailing list from 2006 and just fitted it against v1.19.4.
So far it has been tested to work with busybox v1.19.4.

 .../busybox-1.19.4-start-stop-daemon-rm-pid.patch  |   35 ++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100755 package/busybox/busybox-1.19.4-start-stop-daemon-rm-pid.patch

Comments

Peter Korsgaard Feb. 21, 2013, 8:41 p.m.
>>>>> "Stefan" == Stefan Fröberg <stefan.froberg@petroprogram.com> writes:

 Stefan> Many daemons leave pid files lying around when they are stopped with
 Stefan> start-stop-daemon applet in BusyBox.
 Stefan> This patch will ensure that they are properly cleaned away.

 Stefan> Signed-off-by: Stefan Fröberg <stefan.froberg@petroprogram.com>
 Stefan> ---

 Stefan> Note: I did not make this patch but found it from old thread in BusyBox
 Stefan> mailing list from 2006 and just fitted it against v1.19.4.
 Stefan> So far it has been tested to work with busybox v1.19.4.

Sorry, we don't carry feature patches in Buildroot (certainly not for
actively developed software like Busybox).

Please submit the patch to upstream busybox instead.

Patch hide | download patch | download mbox

diff --git a/package/busybox/busybox-1.19.4-start-stop-daemon-rm-pid.patch b/package/busybox/busybox-1.19.4-start-stop-daemon-rm-pid.patch
new file mode 100755
index 0000000..db199a3
--- /dev/null
+++ b/package/busybox/busybox-1.19.4-start-stop-daemon-rm-pid.patch
@@ -0,0 +1,35 @@ 
+diff -Naur busybox-1.19.4.org/debianutils/Config.src busybox-1.19.4/debianutils/Config.src
+--- busybox-1.19.4.org/debianutils/Config.src	2013-02-21 15:56:12.056163205 +0200
++++ busybox-1.19.4/debianutils/Config.src	2013-02-21 15:59:21.369223915 +0200
+@@ -58,6 +58,15 @@
+ 	  termination of system-level processes, usually the ones
+ 	  started during the startup of the system.
+ 
++config FEATURE_START_STOP_DAEMON_REMOVE_PIDFILE
++	bool "Remove pidfile on stop"
++	default y
++	depends on START_STOP_DAEMON
++	help
++	  If a pidfile is specified when a process is scheluded
++	  to be stopped, remove the pidfile after the process
++	  is successfully stopped.
++
+ config FEATURE_START_STOP_DAEMON_FANCY
+ 	bool "Support additional arguments"
+ 	default y
+diff -Naur busybox-1.19.4.org/debianutils/start_stop_daemon.c busybox-1.19.4/debianutils/start_stop_daemon.c
+--- busybox-1.19.4.org/debianutils/start_stop_daemon.c	2013-02-21 15:56:12.056163205 +0200
++++ busybox-1.19.4/debianutils/start_stop_daemon.c	2013-02-21 16:03:38.119855595 +0200
+@@ -353,8 +353,11 @@
+ 	if (!QUIET && killed) {
+ 		printf("stopped %s (pid", what);
+ 		for (p = G.found_procs; p; p = p->next)
+-			if (p->pid)
++			if (p->pid) {
+ 				printf(" %u", (unsigned)p->pid);
++				if (ENABLE_FEATURE_START_STOP_DAEMON_REMOVE_PIDFILE)
++					unlink(pidfile);
++			}
+ 		puts(")");
+ 	}
+  ret: