[package] base-files: introduce service_kill() into functions.sh - a convenience...
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sun, 19 Sep 2010 14:03:32 +0000 (14:03 +0000)
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sun, 19 Sep 2010 14:03:32 +0000 (14:03 +0000)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@23087 3c298f89-4303-0410-b956-a3cf2f4a3e73

package/base-files/Makefile
package/base-files/files/etc/functions.sh

index bdaf53c..7abcd8b 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=54
+PKG_RELEASE:=55
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
 PKG_BUILD_DEPENDS:=opkg/host
index d5ffc13..c5df499 100755 (executable)
@@ -275,4 +275,21 @@ uci_apply_defaults() {
        uci commit
 }
 
+service_kill() {
+       local name="${1}"
+       local pid="${2:-$(pidof "$name")}"
+       local grace="${3:-5}"
+
+       [ -f "$pid" ] && pid="$(head -n1 "$pid" 2>/dev/null)"
+
+       for pid in $pid; do
+               [ -d "/proc/$pid" ] || continue
+               local try=0
+               kill -TERM $pid 2>/dev/null && \
+                       while grep -qs "$name" "/proc/$pid/cmdline" && [ $((try++)) -lt $grace ]; do sleep 1; done
+               kill -KILL $pid 2>/dev/null && \
+                       while grep -qs "$name" "/proc/$pid/cmdline"; do sleep 1; done
+       done
+}
+
 [ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh
This page took 0.029288 seconds and 4 git commands to generate.