]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/ld: close outfile before cleanup
authorJonathan Rudenberg <jonathan@titanous.com>
Mon, 29 Sep 2014 19:13:22 +0000 (12:13 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 29 Sep 2014 19:13:22 +0000 (12:13 -0700)
This prevents the temporary directory from being leaked when
the linker is run on a FUSE filesystem.

Fixes #8684.

LGTM=bradfitz
R=golang-codereviews, rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/141840043

src/cmd/ld/lib.c

index f889aba8a98db5a033742180a6c6eb1846b51097..910201bdbb7abe91295a6394a39c4ed87f32647c 100644 (file)
@@ -531,8 +531,9 @@ char* mktempdir(void);
 void removeall(char*);
 
 static void
-rmtemp(void)
+cleanup(void)
 {
+       close(cout);
        removeall(tmpdir);
 }
 
@@ -547,7 +548,7 @@ hostlinksetup(void)
        // create temporary directory and arrange cleanup
        if(tmpdir == nil) {
                tmpdir = mktempdir();
-               atexit(rmtemp);
+               atexit(cleanup);
        }
 
        // change our output to temporary object file