]> TLD Linux GIT Repositories - rc-scripts.git/blobdiff - lib/makepid
- merged changes from PLD, all TLD changes and fixes are kept
[rc-scripts.git] / lib / makepid
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