From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on sa.int.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.2.5 Message-ID: <49C562C6.9030704@kalina.in.ua> Date: Sat, 21 Mar 2009 23:57:26 +0200 From: Yura Kalinichenko User-Agent: Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.8.1.18) Gecko/20081114 SeaMonkey/1.1.13 MIME-Version: 1.0 To: ALT Linux Community general discussions References: <493F8D1F.10304@mail.ru> <200812102156.04579.alexey.borovskoy@gmail.com> <49C54DCD.1050001@mail.ru> In-Reply-To: <49C54DCD.1050001@mail.ru> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Comm] =?koi8-r?b?+sXSy8HMydLP18HOycUg0M8g0sHT0MnTwc7JwC4=?= X-BeenThere: community@lists.altlinux.org X-Mailman-Version: 2.1.10b3 Precedence: list Reply-To: ALT Linux Community general discussions List-Id: ALT Linux Community general discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Mar 2009 21:57:51 -0000 Archived-At: List-Archive: List-Post: Vladimir Karpinsky =D0=C9=DB=C5=D4: > =FA=C4=D2=C1=D7=D3=D4=D7=D5=CA=D4=C5! > > Alexey Borovskoy =D0=C9=DB=C5=D4: >> * =F3=D2=C5=C4=C1 10 =C4=C5=CB=C1=C2=D2=D1 2008 Vladimir Karpinsky >> >> --=CB=D5=D3=D8-- >> >> #!/bin/bash >> >> exit_handler() { >> trap - EXIT >> [ -f "$LOCK_FILE" ] && rm -f "$LOCK_FILE" >> } >> >> trap exit_handler HUP PIPE INT QUIT TERM EXIT >> >> date> "$LOCK_FILE" >> >> --=CB=D5=D3=D8-- >> >> =EC=CF=C7=C9=CB=D5 =C4=CF=D0=C9=D3=C1=D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CD=C1=CE=C4=C5=20 > exit =C9 =C1=D7=D4=CF=CD=C1=D4=CF=CD =D5=C2=C9=D7=C1=C5=D4 lock-=C6=C1=CA= =CC, =D4.=C5. =D0=D2=C9 =D4=D2=C5=D4=D8=C5=CD =DA=C1=D0=D5=D3=CB=C5 =D3=CB= =D2=C9=D0=D4=C1=20 > =D5=D6=C5 lock-=C6=C1=CA=CC =CE=C5 =C2=D5=C4=C5=D4 =CE=C1=CA=C4=C5=CE, = =C9 =D3=CB=D2=C9=D0=D4 =C2=D5=C4=C5=D4 =D0=D9=D4=C1=D4=D8=D3=D1 =D2=C1=C2= =CF=D4=C1=D4=D8, =DE=C5=C7=CF=20 > =C2=D9 =CE=C5 =C8=CF=D4=C5=CC=CF=D3=D8. =EE=C5 =CD=CF=C7=D5 =D3=CF=CF=C2= =D2=C1=DA=C9=D4=D8, =CB=C1=CB =DC=D4=CF =CF=C2=CF=CA=D4=C9. > =EF=C2=D9=DE=CE=CF =C2=CC=CF=CB=C9=D2=CF=D7=CB=C9 =D7=D9=D0=CF=CC=CE=D1=C0= =D4=D3=D1 =CE=C5=D3=CB=CF=CC=D8=CB=CF =C4=D2=D5=C7=C9=CD =CF=C2=D2=C1=DA=CF= =CD. =F7=CF=D4 =D0=D2=C9=CD=C5=D2,=20 =CE=C1=C4=C5=C0=D3=D8, =C4=CF=D3=D4=C1=D4=CF=DE=CE=CF =D0=CF=CE=D1=D4=CE=CF= , =DE=D4=CF =D7=C1=DB=C9=C8 =D0=D2=CF=C2=CC=C5=CD =DA=C4=C5=D3=D8 =CE=C5 = =C2=D5=C4=C5=D4: ---------------------------cut----------------------------- USE_LOCK=3Dyes LOCKDIR=3D/tmp LOCKFILE=3Dtest.pid mypid=3D$$ test_lock() { LOCK_LOOP_COUNT=3D10 test "$USE_LOCK" \!=3D "yes" && return 0 set -o noclobber until echo $mypid > $LOCKDIR/$LOCKFILE ; do kill -0 `cat $LOCKDIR/$LOCKFILE` || rm -f $LOCKDIR/$LOCKFILE if [ -f "$LOCKDIR/$LOCKFILE" ]; then echo "Locking ($LOCK_LOOP_COUNT)..." let LOCK_LOOP_COUNT-- if [ $LOCK_LOOP_COUNT -eq 0 ]; then break else sleep 1 fi else echo "Remove stalled lock" fi done set +o noclobber if [ $LOCK_LOOP_COUNT -eq 0 ]; then return 1 else return 0 fi } test_unlock() { test -f $LOCKDIR/$LOCKFILE -a $mypid -eq `cat $LOCKDIR/$LOCKFILE` && rm= -f $LOCKDIR/$LOCKFILE return $? } ---------------------------cut----------------------------- --=20 SY,=20 Yura Kalinichenko