File sysstat-8.1.6-sa1sa2lock.diff of Package sysstat

--- sysstat-11.0.0/sa1.in	2014-06-08 10:56:25.000000000 -0400
+++ sa1.in	2014-07-17 21:54:29.822812673 -0400
@@ -22,15 +22,21 @@
 	SADC_OPTIONS="${SADC_OPTIONS} -D"
 fi
 
+set -e
 ENDIR=@SA_LIB_DIR@
 cd ${ENDIR}
+LOCKFILE=/var/run/sysstat/sadc.LOCK
+mkdir -p /var/run/sysstat
+lockfile -r2 -30 "$LOCKFILE" 2>/dev/null
+trap "/bin/rm -f $LOCKFILE" EXIT
+
 [ "$1" = "--boot" ] && shift && BOOT=y || BOOT=n
 if [ $# = 0 ] && [ "${BOOT}" = "n" ]
 then
 # Note: Stats are written at the end of previous file *and* at the
 # beginning of the new one (when there is a file rotation) only if
 # outfile has been specified as '-' on the command line...
-	exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} 1 1 ${SA_DIR}
+	 ${ENDIR}/sadc -F -L ${SADC_OPTIONS} 1 1 ${SA_DIR}
 else
-	exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} $* ${SA_DIR}
+	 ${ENDIR}/sadc -F -L ${SADC_OPTIONS} $* ${SA_DIR}
 fi
--- sysstat-11.0.0/sa2.in	2014-06-09 15:12:32.000000000 -0400
+++ sa2.in	2014-07-17 21:58:56.852794414 -0400
@@ -33,6 +33,17 @@
 
 [ -f "$DFILE" ] || exit 0
 cd ${ENDIR}
+
+LOCKFILE=/var/run/sysstat/sadc.LOCK
+mkdir -p /var/run/sysstat
+if ! lockfile -r6 -600 $LOCKFILE 2>/dev/null; then
+  if test `find $LOCKFILE -mmin +180 2>/dev/null`; then
+    rm -f $LOCKFILE
+    logger -p cron.alert "$0: detected an old lockfile \"$LOCKFILE\"."
+  fi
+fi
+trap "/bin/rm -f $LOCKFILE" EXIT
+
 ${ENDIR}/sar $* -f ${DFILE} > ${RPT}
 
 find ${SA_DIR} \( -name 'sar??' -o -name 'sa??' -o -name 'sar??.xz' -o -name 'sa??.xz' -o -name 'sar??.gz' -o -name 'sa??.gz' -o -name 'sar??.bz2' -o -name 'sa??.bz2' \) \