summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/common.sh b/lib/common.sh
index b39bbbc..9446ff5 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -130,3 +130,27 @@ get_full_version() {
fi
fi
}
+
+##
+# usage : lock( $fd, $file, $message )
+##
+lock() {
+ eval "exec $1>"'"$2"'
+ if ! flock -n $1; then
+ stat_busy "$3"
+ flock $1
+ stat_done
+ fi
+}
+
+##
+# usage : slock( $fd, $file, $message )
+##
+slock() {
+ eval "exec $1>"'"$2"'
+ if ! flock -sn $1; then
+ stat_busy "$3"
+ flock -s $1
+ stat_done
+ fi
+}