| |
| |
| #include <stdio.h> |
| #include <unistd.h> |
| #include "test.h" |
| |
| int main(void) |
| { |
| char buf[1]; |
| size_t n; |
| int fd; |
| |
| |
| fd = dup(0); |
| close(0); |
| |
| n = fread(buf, 1, sizeof buf, stdin); |
| if (n != 0 || !ferror(stdin)) |
| t_error("fread(stdin) should have failed, got %d ferror %d feof %d\n", |
| n, ferror(stdin), feof(stdin)); |
| if (dup(fd) != 0) |
| t_error("dup failed\n"); |
| |
| rewind(stdin); |
| if (ferror(stdin)) |
| t_error("rewind failed to clear ferror\n"); |
| return t_status; |
| } |