plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit 93e2e820a5551ba3d0a1e0f0fbd4c5eb65e18ce6
parent f6c9f7b14c9dce53fff6020200b28c4e25621e87
Author: Russ Cox <rsc@swtch.com>
Date:   Fri, 24 Jan 2020 13:08:36 -0500

acme: report close failure in Put, this time for sure

Missed in 0b349f6f that Bterm is not closing fd.

Diffstat:
Msrc/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 @@ -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: