Commit 36b64ac0 authored by Rusty Russell's avatar Rusty Russell

Fix run-read_all and fix hang if they should fail.

parent 75e8c217
......@@ -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)));
......
......@@ -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)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment