Patch by Vasilis Kaoutsis: select() and pselect() set errno correctly now.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22499 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-10-10 14:13:34 +00:00
parent 013f781f47
commit d9769e2219

View File

@ -1,22 +1,34 @@
/*
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the OpenBeOS License.
*/
#include <errno.h>
#include <sys/select.h>
#include <syscalls.h>
#define RETURN_AND_SET_ERRNO(err) \
if (err < 0) { \
errno = err; \
return -1; \
} \
return err;
int
pselect(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
struct fd_set *errorBits, const struct timespec *tv, const sigset_t *sigMask)
{
int status;
bigtime_t timeout = -1LL;
if (tv)
timeout = tv->tv_sec * 1000000LL + tv->tv_nsec / 1000LL;
return _kern_select(numBits, readBits, writeBits, errorBits, timeout, sigMask);
status = _kern_select(numBits, readBits, writeBits, errorBits, timeout, sigMask);
RETURN_AND_SET_ERRNO(status);
}
@ -24,10 +36,12 @@ int
select(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
struct fd_set *errorBits, struct timeval *tv)
{
int status;
bigtime_t timeout = -1LL;
if (tv)
timeout = tv->tv_sec * 1000000LL + tv->tv_usec;
return _kern_select(numBits, readBits, writeBits, errorBits, timeout, NULL);
}
status = _kern_select(numBits, readBits, writeBits, errorBits, timeout, NULL);
RETURN_AND_SET_ERRNO(status);
}