I'm trying to write some data to a file. fwrite is returning EAGAIN and fwrite_explain says:
2: fwrite(ptr = 0x7F41EFBC09A8, size = 4066, nmemb = 1, fp = 0x02F79200 "/home/user/asdf.txt") failed, Resource temporarily unavailable (11, EAGAIN) because the file descriptor has been marked non-blocking (O_NONBLOCK) and the write would block
2: fwrite(ptr = 0x17ECFFA40, size = 4066, nmemb = 1, fp = 0x02F79200 "/home/user/asdf.txt") failed, No such file or directory (2, ENOENT) because the file is on a file system ("/home", 1% full) which does not support Unix open file semantics, and the file has been deleted from underneath you
2: fwrite(ptr = 0x17ECFF100, size = 4066, nmemb = 1, fp = 0x02F79200 "/home/user/asdf.txt") failed, No such file or directory (2, ENOENT) because the file is on a file system ("/home", 1% full) which does not support Unix open file semantics, and the file has been deleted from underneath you
I assume the second set of warnings are invalid (the file never gets removed, it's still there).
I never set my file as non-blocking, and I don't care if it blocks because I want to write the data, regardless of how long it may take. What gives?
The relevant code:
fd = fopen(file_to_write, "w");
if (fd == NULL) printf("%d could not open file\n", errno);
n = fwrite((void*)h->bufs[i], write_size, 1, fd);
if (n != write_size) {
printf("%d: %s\n", errno, explain_fwrite((void*)h->bufs[i], write_size, 1, fd));