X-Git-Url: https://git.tld-linux.org/?a=blobdiff_plain;f=lib%2Fmakepid;fp=lib%2Fmakepid;h=224b43138b5a52fff13d8fa4430da4ea76c4de97;hb=49ade4f4b5b1978db4561d62063008a339a1526f;hp=0000000000000000000000000000000000000000;hpb=2d25be2988d266692b556fbcc89c5b9108cf16f8;p=rc-scripts.git 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