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) { switch(request) {
case FIONBIO: case FIONBIO:
value = va_arg(ap, int*); value = va_arg(ap, int*);
if(value == NULL) ret = -1; if(value == NULL) {
else if(*value) { errno = EFAULT;
flags = fcntl(fd, F_GETFL, 0); ret = -1;
ret = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
} }
else {
flags = fcntl(fd, F_GETFL, 0); 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; break;
default: default: