Subject: ftruncate
To: None <>
From: Robert Dobbs <>
List: current-users
Date: 07/19/1994 01:22:24
I'm having trouble with ftruncate with current sources on i386 in both
shared and -static modes.

Basically, ftruncate() doesn't work with files opened as "a" or "r+"
(which may be as designed, the man page is vague).  It also fails to
work when the file has had data written to it.  Finally, it always
(even when it works) returns an error and sets errno = 27

I sent a bug report on this in earlier this evening.

#include <stdio.h>
#include <errno.h>
extern int errno;

	FILE *fp;

	fp = fopen("foo","w");
	fprintf(fp,"Mom loves you");
printf("%d\n", errno);
printf("trunc: %d\n",ftruncate(fileno(fp),10));
printf("%d\n", errno);