From: Randal L. Schwartz Date: Wed, 20 Dec 2006 15:42:05 GMT Subject: Re: [RFC/PATCH] Implement poor-man's submodule support using commit hooks Message-ID: <86y7p21smq.fsf@blue.stonehenge.com> In-Reply-To: <200612201440.41784.andyparkins@gmail.com> >>>>> "Andy" == Andy Parkins writes: Andy> fd_old = open( "someexistingfile" ); Andy> unlink( "someexistingfile" ); Andy> fd_new = open( "someexistingfile" ); This is dangerous if the process aborts suddenly. Might be better to do this: mumble_command < thefile > thefile.$$ mv thefile.$$ thefile The second move will be atomic. The only problem will be if the process aborts, which will leave stale temp files around. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.