You are
not protected against the race condition I
mentioned earlier. An unlink in Unix does not release the
data from the file
until the last file descriptor is closed. The second
process
will be able to read whatever information
is in there (and write to it if it desires). Of course
other processes wont know this since the file's name
space entry is gone. The second process will
continue under the assumption that it was accessing the
locked file in a valid state (hey it was there when I
opened it!).
In some cases, perhaps the
current one, this is ok
in others it is not -- it depends on the assumptions
being made after this section of code. In general if
you are going to do this, it is a good idea to put
a comment in your code that says you know about the
possible race condition and it is ok.