unlink safe before close?

David Harrison harrison at utfyzx.uucp
Sun May 7 19:32:22 AEST 1989


In article <755 at unify.UUCP> rk at unify.UUCP (Ron Kuris) writes:
>I heard from someone in our organization that the following code
>was non-portable.  Does anyone know of some machines were it does
>not work?  Obviously MS/DOS will fail (but who cares?).
> ...
>    if ((fd = creat("/tmp/who-cares", 0600)) < 0)
>	...
>    unlink("/tmp/who-cares");
>	...
>    /* finally just exit which closes and cleans up everything */
>    exit(0);

This *should* work on all UNIX systems, so far as I know. It is a
standard trick to automagically remove tmp files when the process
dies.
I also know for a fact that it does *not* work on an HP9000 Series 
500 running HP-UX (System V.2), a fact which has pained me for a 
number of years.  
So, your colleague is correct.  Whether or not the discontinued
HP9000s500 is alone is this particular brain-damage you may be
finding out from your posting.
-- 
David Harrison                            | "God does not play dice with
Dept. of Physics, Univ of Toronto         |  the universe." -- Einstein
UUCP: uunet!attcan!utgpu!utfyzx!harrison  | "Quit telling God what to
BITNET: HARRISON at UTORPHYS                 |  do." -- Neils Bohr



More information about the Comp.unix.wizards mailing list