Path: utzoo!utgpu!utfyzx!harrison From: harrison@utfyzx.uucp (David Harrison) Date: Sun May 7 05:32:22 EDT 1989 Message-ID: <1989May7.053222.21348@utfyzx.uucp> Organization: Dept. of Physics, Univ. of Toronto Newsgroups: comp.unix.wizards Subject: Re: unlink safe before close? References: <755@unify.UUCP> Reply-To: harrison@utfyzx.UUCP (David Harrison) Distribution: na Organization: Dept. of Physics, Univ. of Toronto Keywords: unlink before close In article <755@unify.UUCP> rk@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@UTORPHYS | do." -- Neils Bohr