diff --git a/Shorewall-core/lib.common b/Shorewall-core/lib.common index 7567123a7..205fc705f 100644 --- a/Shorewall-core/lib.common +++ b/Shorewall-core/lib.common @@ -766,23 +766,22 @@ mutex_on() rm -f ${lockf} error_message "WARNING: Stale lockfile ${lockf} removed" elif [ $lockpid -eq $$ ]; then - return 0 - elif ! ps | grep -v grep | qt grep ${lockpid}; then + fatal_error "Mutex_on confusion" + elif ! qt ps --pid ${lockpid}; then rm -f ${lockf} error_message "WARNING: Stale lockfile ${lockf} from pid ${lockpid} removed" fi fi if qt mywhich lockfile; then - lockfile -${MUTEX_TIMEOUT} -r1 ${lockf} + lockfile -${MUTEX_TIMEOUT} -r1 ${lockf} || fatal_error "Can't lock ${lockf}" g_havemutex="rm -f ${lockf}" chmod u+w ${lockf} echo $$ > ${lockf} chmod u-w ${lockf} elif qt mywhich lock; then - lock ${lockf} - g_havemutex="lock -u ${lockf} && rm -f ${lockf}" - chmod u=r ${lockf} + lock ${lockf} || fatal_error "Can't lock ${lockf}" + g_havemutex="lock -u ${lockf}" else while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do sleep 1