Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: $Revision: 1.6.2.16 $; site prism.UUCP
Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!harpo!decvax!cca!prism!matt
From: matt@prism.UUCP
Newsgroups: net.unix-wizards
Subject: Re: Orphaned Response
Message-ID: <13700001@prism.UUCP>
Date: Wed, 19-Jun-85 22:35:00 EDT
Article-I.D.: prism.13700001
Posted: Wed Jun 19 22:35:00 1985
Date-Received: Thu, 27-Jun-85 08:27:02 EDT
References: <786@turtlevax.UUCP>
Lines: 29
Nf-ID: #R:turtlevax:-78600:prism:13700001:177600:1411
Nf-From: prism!matt    Jun 19 22:35:00 1985


/**** prism:net.unix-wizar / turtlevax!ken /  7:46 pm  Jun 10, 1985 ****/
In article <340@cmu-cs-edu1.ARPA> hua@cmu-cs-edu1.ARPA (Ernest Hua) writes:
>Does anyone have any idea how to truncate a file at the current point in
>writing if it is opened by open()?  I cannot use creat() because the file
>is being used by another process, and I cannot use unlink() it is likely
>that it is linked.  If the updated contents is longer than the original,
>it is not a problem because the file length is just extended.  But if the
>updated contents is shorter, the file does not shrink.  We have 4.1BSD on
>several 780's and 750's.

try

size = lseek(fd, 0L, 1);	/* tell(fd) */
ftruncate(fd, size);		/* int fd, size; */

It's yet another undocumented feature on 4.2.
/* ---------- */

Ah, but if you look carefully, you'll see that the original poster
(Ernest Hua) states very clearly that he's using 4.1, NOT 4.2 BSD.   If
I recall correctly, there's no equivilent of truncate() or ftruncate()
in 4.1.  [By the way, both of these functions are perfectly well
documented in our copy of 4.2 - why not in yours?]

-----------------------------------------------------------------------------
 Matt Landau            {cca, datacube, ihnp4, inmet, mit-eddie, wjh12}...
 Mirror Systems, Inc.                                   ...mirror!prism!matt
-----------------------------------------------------------------------------