Unit testing error conditions - EINTR
In short, how do you unit test an error condition such as EINTR on a system call. One particular example I'm working on, which could be a case all by itself, is whether it's necessary to call fclose again when it returns EOF with (errno==EINTR). The behavior depends on the implementation of fclose: // Given an open FILE *fp while (fclose(fp)==EOF && errno==EINTR) { errno = 0; } This call can be unsafe if fp freed when EINTR occurs. How can I test the error handling for when (errno==EINTR)? In this particular case, it's not safe to call fclose() again, as the C standard says the stream is