Update of /cvsroot/lastbash/lastbash
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv4057
Modified Files:
lastbash
Log Message:
Prevent race conditions in remote calls.
Index: lastbash
===================================================================
RCS file: /cvsroot/lastbash/lastbash/lastbash,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- lastbash 5 Dec 2006 16:42:36 -0000 1.77
+++ lastbash 5 Dec 2006 16:46:38 -0000 1.78
@@ -1605,10 +1605,9 @@
{
# $@ - the commands
- if [ -f "${COMMAND_FILE_LOCK}" ]
+ # Check and create the lock
+ if ( set -o noclobber; echo "$$" > "${COMMAND_FILE_LOCK}" ) 2>/dev/null
then
- echo "Lockfile present, commands not sent"
- else
# Create the lock
echo "$$" > "${COMMAND_FILE_LOCK}"
# Send the commands
@@ -1617,6 +1616,8 @@
rm -f "${COMMAND_FILE_LOCK}"
# Signal the first instance
kill -HUP "$(< $PID_FILE)"
+ else
+ echo "Lockfile present, commands not sent"
fi
}
@@ -1652,13 +1653,9 @@
{
local CMD ARGS
- if [ -f "${COMMAND_FILE_LOCK}" ]
+ # Check and create the lock
+ if ( set -o noclobber; echo "$$" > "${COMMAND_FILE_LOCK}" ) 2>/dev/null
then
- tui_sbar "Lockfile present, remote call ignored"
- else
- # Create the lock
- echo "$$" > "${COMMAND_FILE_LOCK}"
-
# Check the command file exists
if [ -f "${COMMAND_FILE}" ]
then
@@ -1677,6 +1674,8 @@
# Remove the lock
rm -f "${COMMAND_FILE_LOCK}"
+ else
+ tui_sbar "Lockfile present, remote call ignored"
fi
# Restore the status bar
|