From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3647 invoked from network); 10 May 2006 10:10:25 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 May 2006 10:10:25 -0000 Received: (qmail 10513 invoked from network); 10 May 2006 10:10:17 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 May 2006 10:10:17 -0000 Received: (qmail 25280 invoked by alias); 10 May 2006 10:10:11 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10235 Received: (qmail 25269 invoked from network); 10 May 2006 10:10:11 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 May 2006 10:10:11 -0000 Received: (qmail 9544 invoked from network); 10 May 2006 10:10:10 -0000 Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by a.mx.sunsite.dk with SMTP; 10 May 2006 10:10:09 -0000 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1Fdldq-0001px-F7 for zsh-users@sunsite.dk; Wed, 10 May 2006 12:10:02 +0200 Received: from hippo.e-hippo.net ([216.182.10.250]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 10 May 2006 12:10:02 +0200 Received: from ljz by hippo.e-hippo.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 10 May 2006 12:10:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@sunsite.dk From: Lloyd Zusman Subject: Re: File locking within zsh? Date: Wed, 10 May 2006 06:02:10 -0400 Message-ID: <877j4ujizh.fsf@asfast.com> References: <87r7324zyh.fsf@asfast.com> <009101c673f7$06b3f090$6500000a@venti> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: hippo.e-hippo.net User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:bRwk9/JABvGwBX91+OO5UFIbDH0= Sender: news "Brian K. White" writes: > From: "Tim Writer" > >> [ ... ] >> >> while ! ln file file.lock 2>/dev/null >> do >> sleep 1 >> done >> # Lock obtained >> >> print foo bar baz >>file >> # do a whole lot of other stuff to "file" >> >> rm -f file.lock >> # Lock released >> >> Wrapping this idiom into lock/unlock functions is left as an exercise >> for the >> reader. :-) > > > Is that better or worse, and why, than umask 222 ; >file ? > > http://www.unix.org.ua/orelly/unix/upt/ch45_36.htm Thanks to both of you (Brian K. White and Tim Writer). I personally like the umask version better, because I think I can implement a variation of it without spawning any extra processes (my goal), given that umask is an internal zsh command. -- Lloyd Zusman ljz@asfast.com God bless you.