From 93e2e820a5551ba3d0a1e0f0fbd4c5eb65e18ce6 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 24 Jan 2020 13:08:36 -0500 Subject: acme: report close failure in Put, this time for sure Missed in 0b349f6f that Bterm is not closing fd. --- src/cmd/acme/exec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index 1d50f92f..be7936ae 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -699,7 +699,7 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) Rune *r; Biobuf *b; char *s, *name; - int i, fd, q, ret; + int i, fd, q, ret, retc; Dir *d, *d1; Window *w; int isapp; @@ -763,9 +763,10 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) goto Rescue2; } ret = Bterm(b); + retc = close(fd); free(b); b = nil; - if(ret < 0) { + if(ret < 0 || retc < 0) { warning(nil, "can't write file %s: %r\n", name); goto Rescue2; // flush or close failed } @@ -785,10 +786,9 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) // in case we don't have read permission. // (The create above worked, so we probably // still have write permission.) - close(fd); fd = open(name, OWRITE); - d1 = dirfstat(fd); + close(fd); if(d1 != nil){ free(d); d = d1; @@ -821,11 +821,11 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) if(b != nil) { Bterm(b); free(b); + close(fd); } free(h); fbuffree(s); fbuffree(r); - close(fd); /* fall through */ Rescue1: -- cgit v1.2.3