Skip to contentSkip to conversation

dev-mornfall-nix - test: Avoid a leaked fd when exec'ing tests.

PATCH Petr Rockai 1 participant 1 message May 27, 2013

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ea56a7ea612cf9230307e65ef0bb62c7a0f66df0
Commit:        ea56a7ea612cf9230307e65ef0bb62c7a0f66df0
Parent:        2412716f1726aefcc57be3e2d8ca6f6f8b15b743
Author:        Petr Rockai <[email protected]>
AuthorDate:    Mon May 27 15:52:11 2013 +0200
Committer:     Petr Rockai <[email protected]>
CommitterDate: Mon May 27 15:52:11 2013 +0200

test: Avoid a leaked fd when exec'ing tests.

---
 test/lib/harness.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
test/lib/harness.c +1 -2
index df4177a..e80efbf 100644
@@ -316,8 +316,6 @@ static void run(int i, char *f) {
 		sprintf(outpath, "results/%s.txt", f);
 		while (strchr(outpath + 8, '/'))
 			*strchr(outpath + 8, '/') = '_';
-		if (outfile)
-			fclose(outfile);
 		outfile = fopen(outpath, "w");
 		while ((w = waitpid(pid, &st, WNOHANG)) == 0) {
 			drain();
@@ -340,6 +338,7 @@ static void run(int i, char *f) {
 			failed(i, f, st);
 		}
 		clear();
+		fclose(outfile);
 	}
 }