Morning, On Fri, Sep 13, 2013 at 8:33 AM, Ashley Maher < [email protected]> wrote:
> > What can I put in a test text file to get fgets to fail? > > Can hand indicate the condition fail but would like to trigger a "real" > read failure well into the file. A lot of references about testing for > failure but nothing how to trigger fgets to fail. > > What sort of failure do you expect? You may - seek the pointer at the end of file just before fgets to get eof error - lock part of the file exclusively from another process to get EAGAIN, if mandatory file locking is supported and file was opened with non-blocking flag. - open a pipe instead of regular file and kill other end in process. - send a signal to the process while it's waiting for read (pipe of socket) to get EINTR. - power off you hard drive in process to get real read failure (EIO), if you have nothing to loose on your hdd :) http://www.dataparksearch.org/ Twitter: @Maxime2 -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
