Add errno to error cases for FIONBIO.

This commit is contained in:
mtheall 2014-11-21 11:06:32 -06:00
parent 0db0a11751
commit 550f690c8d

View File

@ -16,15 +16,23 @@ int ioctl(int fd, int request, ...)
switch(request) {
case FIONBIO:
value = va_arg(ap, int*);
if(value == NULL) ret = -1;
else if(*value) {
flags = fcntl(fd, F_GETFL, 0);
ret = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
if(value == NULL) {
errno = EFAULT;
ret = -1;
}
else {
flags = fcntl(fd, F_GETFL, 0);
ret = fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
if(flags == -1) {
errno = SOCU_GetError();
return -1;
}
if(*value) ret = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
else ret = fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
if(ret != 0)
errno = SOCU_GetError();
break;
default: