If you really want to handle this error, please use errno.h instead of -1.