usleep return value check
Status: Beta
Brought to you by:
vgropp
OS: linux mandriva 2009.0
Project version: bwm-ng-0.6
bwm-ng.c:216 if (EINVAL==usleep(delay*1000))
/* there seems to be systems where 1million usecs is max */
usleep(999999);
According to man usleep() possible return values are 0 on success and -1 on error. If the error occures errno is set to EINVAL or EINTR. Linux man seems a bit ambiguity on the case but posix and freebsd man pages states explicitely: "If any of the following conditions occur, the usleep() function shall return -1 and set errno to the corresponding value."
Solution:
if (usleep(delay*1000) != 0)
{
if (errno == EINVAL)
{
errno = 0;
/* there seems to be systems where 1million usecs is max */
usleep(999999);
}
else
{
exit(-1);
}
}
should be fixed in 0.6.1