From: Rusty Russell Date: Fri, 14 Nov 2008 07:13:09 +0000 (+1030) Subject: Fix run-read_all and fix hang if they should fail. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=36b64ac075afbccbc42937f58b3aa9ce5901ebf5;ds=sidebyside Fix run-read_all and fix hang if they should fail. --- diff --git a/ccan/read_write_all/test/run-read_all.c b/ccan/read_write_all/test/run-read_all.c index 2790b64d..5fa0ec39 100644 --- a/ccan/read_write_all/test/run-read_all.c +++ b/ccan/read_write_all/test/run-read_all.c @@ -39,6 +39,8 @@ int main(int argc, char *argv[]) child = fork(); if (!child) { + close(p2c[1]); + close(c2p[0]); /* Child. Make sure parent ready, then write in two parts. */ if (read(p2c[0], &c, 1) != 1) exit(1); @@ -50,13 +52,15 @@ int main(int argc, char *argv[]) /* Make sure they get signal. */ if (read(p2c[0], &c, 1) != 1) exit(4); - if (write(c2p[1], buffer, PIPE_BUF) != PIPE_BUF) + if (write(c2p[1], buffer, BUFSZ) != BUFSZ) exit(5); exit(0); } if (child == -1) err(1, "forking"); + close(p2c[0]); + close(c2p[1]); signal(SIGUSR1, got_signal); ok1(write(p2c[1], &c, 1) == 1); ok1(read_all(c2p[0], buffer, sizeof(buffer))); diff --git a/ccan/read_write_all/test/run-write_all.c b/ccan/read_write_all/test/run-write_all.c index fbfa1f99..379ff923 100644 --- a/ccan/read_write_all/test/run-write_all.c +++ b/ccan/read_write_all/test/run-write_all.c @@ -37,6 +37,7 @@ int main(int argc, char *argv[]) child = fork(); if (!child) { + close(p2c[1]); /* Make sure they started writing. */ if (read(p2c[0], buffer, 1) != 1) exit(1); @@ -54,6 +55,7 @@ int main(int argc, char *argv[]) if (child == -1) err(1, "forking"); + close(p2c[0]); memset(buffer, 0xff, sizeof(buffer)); signal(SIGUSR1, got_signal); ok1(write_all(p2c[1], buffer, sizeof(buffer)));