How can a file be truncated on System V??

Guy Harris guy at auspex.auspex.com
Wed May 3 16:47:52 AEST 1989


>  There was a method in wizards a few years ago I believe. It had to do
>with using O_TRUNC, which seems to truncate to the position of the
>current file pointer.

Not on S5R3.1, and not on 4.3BSD.  O_TRUNC is used *only* on "open", and
since the whole point of "open" is to *create* a file pointer, there
*is* no current file pointer....  O_TRUNC isn't used on "fcntl".

>There was a trick with reopen or dup or ??? which
>allowed opening of an already open file.

Well, "dup" will give you a second file descriptor that refers to an
already-open file, but there's no trick that lets you open an
already-open file with "open", unless you have something like the
"/dev/fd" mechanism.



More information about the Comp.unix.wizards mailing list