Re: [RFC/PATCH] Implement poor-man's submodule support using commit hooks
- From
Randal L. Schwartz <merlyn@stonehenge.com>
- Date
- Dec 20, 2006, 15:42 UTC
- Message-ID
- <86y7p21smq.fsf@blue.stonehenge.com>
- In-Reply-To
- <200612201440.41784.andyparkins@gmail.com>
>>>>> "Andy" == Andy Parkins <andyparkins@gmail.com> 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 <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.