Permalink
Browse files

Still not right. Gonna redo it in perl I think, but save me work!

  • Loading branch information...
Andrew Rodland
Andrew Rodland committed Jul 15, 2009
1 parent 82274a2 commit 0792ea04d2f46cb61463ed80f722afe96e1f6a9b
Showing with 23 additions and 1 deletion.
  1. +23 −1 cat-fcgi-init
View
@@ -39,7 +39,29 @@ else
PIDDIR=/tmp
fi
-PIDFILE=$PIDDIR/$UNIXNAME${PIDSUFFIX:+"-$PIDSUFFIX"}.pid
+serialfile_name() {
+ echo $PIDDIR/$UNIXNAME{$PIDSUFFIX:"-$PIDSUFFIX"}.serial
+}
+
+read_serial() {
+ (
+ flock -s 99
+ read -u 99 SERIAL
+ ) 99<>`serialfile_name`
+}
+
+increment_serial() {
+ (
+ flock -x 99
+ read -u 99 SERIAL
+ echo $(( $SERIAL + 1 )) >`serialfile_name`
+ ) 99<>`serialfile_name`
+}
+
+pidfile_name() {
+ SERIAL=shift
+ echo $PIDDIR/$UNIXNAME${PIDSUFFIX:+"-$PIDSUFFIX"}${SERIAL:+"~$SERIAL"}.pid
+}
check_running() {
[ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1

0 comments on commit 0792ea0

Please sign in to comment.