int main(int argc, char **argv) { char filename[PATH_MAX]; int pid[NUM_CHILDREN]; int num_children = 1; int i; snprintf(filename, sizeof(filename), "%s/aiodio/file", getenv("TMP") ? getenv("TMP") : "/tmp"); for (i = 0; i < num_children; i++) { if ((pid[i] = fork()) == 0) { /* child */ return dio_read(filename); } else if (pid[i] < 0) { /* error */ perror("fork error"); break; } else { /* Parent */ continue; } } /* * Parent creates a zero file using DIO. * Truncates it to zero * Create another file with '0xaa' */ for (i = 0; i < 100; i++) { dio_append(filename, 0); truncate(filename, 0); dio_append("junkfile", 0xaa); truncate("junkfile", 0); } for (i = 0; i < num_children; i++) { kill(pid[i], SIGTERM); } return 0; }
int main(int argc, char **argv) { char filename[PATH_MAX]; int pid[NUM_CHILDREN]; int num_children = 1; int i; snprintf(filename, sizeof(filename), "%s/aiodio/file", getenv("TMP") ? getenv("TMP") : "/tmp"); printf("Begin dio_append test...\n"); for (i = 0; i < num_children; i++) { if ((pid[i] = fork()) == 0) { /* child */ return read_eof(filename); } else if (pid[i] < 0) { /* error */ perror("fork error"); break; } else { /* Parent */ continue; } } /* * Parent appends to end of file using direct i/o */ dio_append(filename); for (i = 0; i < num_children; i++) { kill(pid[i], SIGTERM); } return 0; }