[projects/rc-scripts] daemon: make --makepid work with rc-logging
glen
glen at pld-linux.org
Sat Oct 10 01:32:57 CEST 2015
commit d64dc33640917a00ddfb060452555d0274f54d27
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Thu Oct 8 18:10:31 2015 +0300
daemon: make --makepid work with rc-logging
need a wrapper to achieve this
lib/Makefile.am | 4 ++--
lib/functions | 5 +++++
lib/makepid | 12 ++++++++++++
3 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 22d17fb..0921a76 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -6,7 +6,6 @@ sbin_SCRIPTS = \
tnldown \
tnlup
-#scriptsdir = @networkscriptsdir@
scriptsdir = @exec_prefix@/lib/$(PACKAGE)
scripts_SCRIPTS = \
@@ -28,7 +27,8 @@ scripts_SCRIPTS = \
ifup-ppp \
ifup-routes \
ifup-sl \
- ifup-vlan
+ ifup-vlan \
+ makepid \
scripts_DATA = \
functions \
diff --git a/lib/functions b/lib/functions
index 6ded514..ca08dbe 100644
--- a/lib/functions
+++ b/lib/functions
@@ -690,6 +690,11 @@ _daemon_exec() {
--exec "$prog" \
-- "$@"
else
+ if [ "$makepid" ] && [ "$pidfile" ]; then
+ export PIDFILE="$pidfile"
+ set -- /lib/rc-scripts/makepid "$@"
+ fi
+
if [ "$fork" = "1" ]; then
set -- /usr/bin/setsid "$@"
fi
diff --git a/lib/makepid b/lib/makepid
new file mode 100755
index 0000000..224b431
--- /dev/null
+++ b/lib/makepid
@@ -0,0 +1,12 @@
+#!/bin/sh
+test -n "$PIDFILE" || { echo >&2 'Missing $PIDFILE env'; exit 1; }
+
+# run the program, and capture pid
+prog="$1"; shift
+"$prog" "$@" &
+pid=$!
+rc=$?
+
+# write pid to file
+echo "$pid" > "$PIDFILE"
+exit $rc
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/rc-scripts.git/commitdiff/1a0c02d0983a76562fa875a1bab45ece246b26a6
More information about the pld-cvs-commit
mailing list