summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ctm/ctm
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1995-04-16 22:40:49 +0000
committerbde <bde@FreeBSD.org>1995-04-16 22:40:49 +0000
commit5065e4a36671dae647143d597f1fe901e07e485d (patch)
treeda2a0dc77c3625c3a70eedd0f1a7a8f163b275dd /usr.sbin/ctm/ctm
parent9f2e93e57db76f2836725d989dbc35a3298d25f9 (diff)
downloadFreeBSD-src-5065e4a36671dae647143d597f1fe901e07e485d.zip
FreeBSD-src-5065e4a36671dae647143d597f1fe901e07e485d.tar.gz
Check for i/o errors in fclose() so that a full disk doesn't almost
guarantee truncation of the file being edited.
Diffstat (limited to 'usr.sbin/ctm/ctm')
-rw-r--r--usr.sbin/ctm/ctm/ctm_ed.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/usr.sbin/ctm/ctm/ctm_ed.c b/usr.sbin/ctm/ctm/ctm_ed.c
index 219fafc..4fdf3b9 100644
--- a/usr.sbin/ctm/ctm/ctm_ed.c
+++ b/usr.sbin/ctm/ctm/ctm_ed.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id$
+ * $Id: ctm_ed.c,v 1.4 1994/09/22 02:49:17 phk Exp $
*
*/
@@ -92,12 +92,23 @@ ctm_edit(u_char *script, int length, char *filein, char *fileout)
if(c == EOF) break;
putc(c,fo);
}
- fclose(fi);
- fclose(fo);
- return 0;
+ ret = 0;
bye:
- if(fi) fclose(fi);
- if(fo) fclose(fo);
+ if(fi) {
+ if(fclose(fi) != 0) {
+ perror(filein);
+ ret = 1;
+ }
+ }
+ if(fo) {
+ if(fflush(fo) != 0) {
+ perror(fileout);
+ ret = 1;
+ }
+ if(fclose(fo) != 0) {
+ perror(fileout);
+ ret = 1;
+ }
+ }
return ret;
}
-
OpenPOWER on IntegriCloud