1 /* FIXME: Do something tricky to ensure we really do loop in write_all. */
3 #include "read_write_all/read_write_all.h"
4 #include "read_write_all/read_write_all.c"
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[])
27 char buffer[BUFSZ*2] = { 0 };
34 /* We fork and torture parent. */
41 /* Make sure they started writing. */
42 if (read(p2c[0], buffer, 1) != 1)
44 if (kill(getppid(), SIGUSR1) != 0)
46 if (!read_all(p2c[0], buffer+1, sizeof(buffer)-1))
48 if (memchr(buffer, 0, sizeof(buffer))) {
49 fprintf(stderr, "buffer has 0 at offset %ti\n",
50 memchr(buffer, 0, sizeof(buffer)) - (void *)buffer);
59 memset(buffer, 0xff, sizeof(buffer));
60 signal(SIGUSR1, got_signal);
61 ok1(write_all(p2c[1], buffer, sizeof(buffer)));
63 ok1(wait(&status) == child);
64 ok(WIFEXITED(status) && WEXITSTATUS(status) == 0,
65 "WIFEXITED(status) = %u, WEXITSTATUS(status) = %u",
66 WIFEXITED(status), WEXITSTATUS(status));