From owner-freebsd-questions@FreeBSD.ORG Wed Apr 13 13:23:29 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C39F1065670 for ; Wed, 13 Apr 2011 13:23:29 +0000 (UTC) (envelope-from nvass@gmx.com) Received: from mailout-eu.gmx.com (mailout-eu.gmx.com [213.165.64.42]) by mx1.freebsd.org (Postfix) with SMTP id A89798FC18 for ; Wed, 13 Apr 2011 13:23:28 +0000 (UTC) Received: (qmail invoked by alias); 13 Apr 2011 13:23:27 -0000 Received: from adsl-99.109.242.189.tellas.gr (EHLO [192.168.73.192]) [109.242.189.99] by mail.gmx.com (mp-eu003) with SMTP; 13 Apr 2011 15:23:27 +0200 X-Authenticated: #46156728 X-Provags-ID: V01U2FsdGVkX19/UaEIOv1/renlMqei6EDE/mtFUu4ONFiXCxZCKJ tj3WfVHHtJ+Sqi Message-ID: <4DA5A3B5.4080302@gmx.com> Date: Wed, 13 Apr 2011 16:23:01 +0300 From: Nikos Vassiliadis User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: Bastien Semene References: <4DA56819.90503@cyanide-studio.com> In-Reply-To: <4DA56819.90503@cyanide-studio.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Cc: freebsd-questions@freebsd.org Subject: Re: lockf command X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Apr 2011 13:23:29 -0000 On 4/13/2011 12:08 PM, Bastien Semene wrote: > I wish that if command #2 can't acquire the lock, lockf exits (exit 0 > would be nice). > If I set -t 1, lockf is quite what I'm waiting for. But I like to do > this in a clear way : if it can't acquire the lock it exits, no timeout > wait. > > Am I misunderstanding something ? What should I change ? > You should use -t0, something like: > lab# lockf -t 0 /tmp/lock /bin/csh > You have mail. > lab# lockf -t 0 /tmp/lock /bin/csh > lockf: /tmp/lock: already locked > lab# echo $? > 75 > lab# HTH, Nikos