Safe I/O
Posted: 10 Dec 2004, 14:06
Hi all,
This is a request to engine authors that I already made a few months ago.
When reading input please test for end-of-file, and let the engine quit if encountered. In other words, interpret EOF as "quit" (input has ended so no more commands will ever be received).
I know this is not supposed to happen since the interface should send "quit" first, but the interface (e.g. PolyGlot) can be killed by third-party software before doing so. Be assured that this does happen.
The most popular function for reading input is probably fgets(). Just test the return value for equality with NULL. If you want to go further you can use feof() or ferror() when receiving NULL. In any case it is safe to quit when receiving NULL.
Thanks,
Fabien.
This is a request to engine authors that I already made a few months ago.
When reading input please test for end-of-file, and let the engine quit if encountered. In other words, interpret EOF as "quit" (input has ended so no more commands will ever be received).
I know this is not supposed to happen since the interface should send "quit" first, but the interface (e.g. PolyGlot) can be killed by third-party software before doing so. Be assured that this does happen.
The most popular function for reading input is probably fgets(). Just test the return value for equality with NULL. If you want to go further you can use feof() or ferror() when receiving NULL. In any case it is safe to quit when receiving NULL.
Thanks,
Fabien.