3 ms·
Indeed, errno is not cleared by successful calls, so you can't check it for success. After a short write your only legitimate course of action is to advance th
by jeffbee 6y ago
Indeed, errno is not cleared by successful calls, so you can't check it for success.
After a short write your only legitimate course of action is to advance the pointer and write again.
- nitrogen 6y agoYou can set errno to 0 and see if it changes.
- jeffbee 6y agoThe syscall is allowed to set it even in case of success.
- deleted 6y ago[deleted]
- rwmj 6y agoThis is sort of right, but the behaviour is a bit subtle. errno should never be set to zero by any POSIX-compliant syscall or library call. However it may be set to something (which is non-zero) on a successful call. Ref: https://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html https://pubs.opengroup.org/onlinepubs/9699919799/functions/e...
- FreeFull 6y agoI'm not sure there is any guarantee that a function that completes successfully hasn't changed the value of errno anyway.
- nitrogen 6y agoYeah, I didn't mean to imply that you can ignore the return value.