1 /* FIXME: Do something tricky to ensure we really do loop in write_all. */
3 #include <ccan/read_write_all/read_write_all.h>
4 #include <ccan/read_write_all/read_write_all.c>
5 #include <ccan/tap/tap.h>
16 static volatile int sigcount;
17 static void got_signal(int sig)
22 /* < PIPE_BUF *will* be atomic. But > PIPE_BUF only *might* be non-atomic. */
23 #define BUFSZ (1024*1024)
25 int main(int argc, char *argv[])
32 buffer = calloc(BUFSZ, 1);
35 /* We fork and torture parent. */
42 /* Make sure they started writing. */
43 if (read(p2c[0], buffer, 1) != 1)
45 if (kill(getppid(), SIGUSR1) != 0)
47 if (!read_all(p2c[0], buffer+1, BUFSZ-1))
49 if (memchr(buffer, 0, BUFSZ)) {
50 fprintf(stderr, "buffer has 0 at offset %ti\n",
51 memchr(buffer, 0, BUFSZ) - (void *)buffer);
60 memset(buffer, 0xff, BUFSZ);
61 signal(SIGUSR1, got_signal);
62 ok1(write_all(p2c[1], buffer, BUFSZ));
64 ok1(wait(&status) == child);
65 ok(WIFEXITED(status) && WEXITSTATUS(status) == 0,
66 "WIFEXITED(status) = %u, WEXITSTATUS(status) = %u",
67 WIFEXITED(status), WEXITSTATUS(status));