bw_pipe.c: close pipe descriptors as appropriate

This commit is contained in:
jdolecek 2001-09-22 15:25:32 +00:00
parent e761df1f5d
commit 435eb7d35d
2 changed files with 32 additions and 1 deletions

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.2 2001/04/20 09:13:24 agc Exp $
$NetBSD: distinfo,v 1.3 2001/09/22 15:25:32 jdolecek Exp $
SHA1 (hbench-OS-1.0.tar.gz) = f8461fee712e354072f2764496403a50c1543c24
Size (hbench-OS-1.0.tar.gz) = 205666 bytes
@ -13,3 +13,4 @@ SHA1 (patch-ah) = 6c01c679b394985d0570df4fe29c09642cbde6c3
SHA1 (patch-ai) = d59d05c9d73aa4c06f5ac5153a069694a4267fd1
SHA1 (patch-aj) = 7bca0c1062626b5c03f04b7bce17f7c2d8c14231
SHA1 (patch-ak) = 986d86c1b6d6850585cde8cb9ffd119fbe2351ee
SHA1 (patch-al) = a94603837789248bff873ec787ede901dd1ed215

View file

@ -0,0 +1,30 @@
$NetBSD: patch-al,v 1.1 2001/09/22 15:25:33 jdolecek Exp $
--- bw_pipe.c.orig Fri Sep 21 18:39:15 2001
+++ bw_pipe.c Fri Sep 21 18:39:48 2001
@@ -147,6 +147,8 @@ do_pipexfer(num_iter, t)
/* Spawn off a writer, then time the read */
switch (fork()) {
case 0: /* writer */
+ close(pipes[0]);
+
while ((done < todo) &&
((n = write(pipes[1], buf, bufsize)) > 0))
done += n;
@@ -159,6 +161,8 @@ do_pipexfer(num_iter, t)
/*NOTREACHED*/
default: /* reader */
+ close(pipes[1]);
+
/* wait for writer */
sleep(1);
@@ -168,6 +172,7 @@ do_pipexfer(num_iter, t)
done += n;
*t = stop(); /* stop timing */
+ close(pipes[0]);
wait(&termstat); /* wait for writer to exit */
}