Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!uflorida!novavax!hcx1!hcx3!shirono From: shirono@hcx3.SSD.HARRIS.COM Newsgroups: comp.lang.c Subject: Re: Xenix Message-ID: <44100013@hcx3> Date: 19 Sep 88 16:07:00 GMT References: <171@uniblab.UUCP> Lines: 31 Nf-ID: #R:uniblab.UUCP:171:hcx3:44100013:000:1321 Nf-From: hcx3.SSD.HARRIS.COM!shirono Sep 19 12:07:00 1988 /* Written 3:10 pm Sep 15, 1988 by chip@ateng.UUCP in hcx3:comp.lang.c */ According to english@stromboli.usc.edu (Joe English): >In article <171@uniblab.UUCP> al@uniblab.UUCP (alan krantz) writes: >> If i have an open file and want to set that files length >> to zero, do i have to close the file and reopen it? > >Can't be done; you do have to close() and re- creat() or >open(... | O_TRUNC). int fd1, fd2; fd1 = creat("filename", 0666); write(fd1, "howdy", 5); fd2 = creat("filename", 0666); /* truncates file */ close(fd2); /* but fd1 is still open and available */ /* End of text from hcx3:comp.lang.c */ Also, fd1 is at offset 5. The next write would happen at that point, leaving a hole (or ASCII nul's). ______________________________________________________________________________ || Internet: shirono@ssd.harris.com Roberto Shironoshita || Harris Corporation || ...!novavax---\ Computer Systems Division || UUCP: ...!uunet-------!hcx1!shirono || ...!mit-eddie-/ ------------------------------------------------------------------------------ DISCLAIMER: The opinions expressed here are my own; they in no way reflect the opinion or policies of Harris Corporation.