]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
daemon: make --makepid work with rc-logging
authorElan Ruusamäe <glen@delfi.ee>
Thu, 8 Oct 2015 15:10:31 +0000 (18:10 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Thu, 8 Oct 2015 15:10:33 +0000 (18:10 +0300)
need a wrapper to achieve this

lib/Makefile.am
lib/functions
lib/makepid [new file with mode: 0755]

index 22d17fb5c76e4071f9ea382affb03b07052f32ae..0921a76b7243bb87f513b081ffe005dde8926b9d 100644 (file)
@@ -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 \
index 6ded51470f77b561bc81aa26f07f05cc4649afe9..ca08dbe100799640aad0be6e9d2cd953e381fc60 100644 (file)
@@ -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 (executable)
index 0000000..224b431
--- /dev/null
@@ -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
This page took 0.107098 seconds and 4 git commands to generate.