source: soft/build_system/build_system/upload/robot/trunk/robot-lock @ 1

Last change on this file since 1 was 1, checked in by fasma, 13 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 448 bytes
Line 
1# to be sourced
2
3LOCK=$1
4if [ -z "$LOCK" ]; then
5    echo "syntax: $0 <lock file>"
6    exit 1
7fi
8
9if [ -e "$LOCK" ]; then
10    pid=`cat $LOCK`
11    if [ "$pid" -gt 0 ]; then
12        if [ ! -d /proc/$pid ]; then
13            echo "stale lock: removing it"
14            rm -f "$LOCK"
15        else
16            while [ -d /proc/$pid ]; do
17                if [ -n "$*" ]; then
18                    echo "exiting because $pid is already running"
19                fi
20                exit
21            done
22        fi
23    fi
24fi
25
26echo "$$" > $LOCK
27trap "rm -f $LOCK" 0
Note: See TracBrowser for help on using the repository browser.