Patchwork libgo patch committed: Make sure file is not closed early

login
register
mail settings
Submitter Ian Taylor
Date Feb. 1, 2012, 9:02 p.m.
Message ID <mcrpqdyclnw.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/139005/
State New
Headers show

Comments

Ian Taylor - Feb. 1, 2012, 9:02 p.m.
This patch to libgo fixes the test for leaked file descriptors.  In some
cases the file, expected to be open, could be collected by the garbage
collector and closed.  This then caused the next call to open to return
that descriptor rather than the expected one, causing the test to fail.
This patch adds an explicit close, ensuring that the file can not be
collected.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

Index: libgo/go/os/exec/exec_test.go
===================================================================
--- libgo/go/os/exec/exec_test.go	(revision 183650)
+++ libgo/go/os/exec/exec_test.go	(working copy)
@@ -292,6 +292,7 @@  func TestHelperProcess(*testing.T) {
 				f.Close()
 			}
 		}
+		fd3.Close()
 		os.Stderr.Write(bs)
 	case "exit":
 		n, _ := strconv.Atoi(args[0])