Bug in MS C unlink() ?

John Campbell jdc at naucse.UUCP
Tue Mar 14 06:32:40 AEST 1989


>From article <89Mar13.100742est.10755 at ephemeral.ai.toronto.edu>, by bradb at ai.toronto.edu (Brad Brown):
> In article <1032 at infmx.UUCP> aland at infmx.UUCP (Dr. Scump) writes:
>>I ran into a nasty problem with unlink() in Microsoft C's unlink()
>>call (MS C 4.0 and 5.1).  It seems that if one unlinks an *open*
>>file on a hard disk, the result is lost clusters!   the unlink()
>>call itself returns 0.
>>
> 
> This makes sense, given how the operating system works.  (That's not to say
> that PC users (like myself) would not be much better off with a *real* 
> operating system :-)  I don't think this is a bug, just an evilness on the
> part of the operating system.
> 
> The problem occurs for the following reason:  DOS is not smart enough to
> hold an unlink()ed file open until it is close()d, so the file just
> 
> Unfortunately, compatability constraints and general dumbness of the 
> operating system preclude an easy answer.

If you change the above from "DOS is not smart..." to "VMS is not smart..."
you have a common VMS situation as well.  One difference, however, is that
Digital doesn't pretend to provide an unlink() as part of the 'C' RTL under
VMS.  This is good; it forces the programmer to look at what is really
happening in the code.  Is unlink() just a delete(), or is unlink() providing
a temporary file that will go away at the close?

VMS also has the strange habit of really closing stdout if you dup() and
then close() one of the file descriptors.  This problem (which is sort
of rare, but did happen to me in gnuplot) is really a bug in my way
of thinking.

Oh well, I just followed up to suggest that MSC and PC implementors shouldn't
provide an unlink() that is not compatible with the unix counter part.  And
VMS shouldn't provide dup() unless it can properly decrement and close()
descriptors.  Also, I have wished, at times, that unix programmers would 
unlink() since this is a very operating specific idea.
-- 
	John Campbell               ...!arizona!naucse!jdc
                                    CAMPBELL at NAUVAX.bitnet
	unix?  Sure send me a dozen, all different colors.



More information about the Comp.lang.c mailing list