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:
@@ -1,22 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2002-2004, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2002-2007, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
* Distributed under the terms of the OpenBeOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define RETURN_AND_SET_ERRNO(err) \
|
||||||
|
if (err < 0) { \
|
||||||
|
errno = err; \
|
||||||
|
return -1; \
|
||||||
|
} \
|
||||||
|
return err;
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
pselect(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
|
pselect(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
|
||||||
struct fd_set *errorBits, const struct timespec *tv, const sigset_t *sigMask)
|
struct fd_set *errorBits, const struct timespec *tv, const sigset_t *sigMask)
|
||||||
{
|
{
|
||||||
|
int status;
|
||||||
bigtime_t timeout = -1LL;
|
bigtime_t timeout = -1LL;
|
||||||
if (tv)
|
if (tv)
|
||||||
timeout = tv->tv_sec * 1000000LL + tv->tv_nsec / 1000LL;
|
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,
|
select(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
|
||||||
struct fd_set *errorBits, struct timeval *tv)
|
struct fd_set *errorBits, struct timeval *tv)
|
||||||
{
|
{
|
||||||
|
int status;
|
||||||
bigtime_t timeout = -1LL;
|
bigtime_t timeout = -1LL;
|
||||||
if (tv)
|
if (tv)
|
||||||
timeout = tv->tv_sec * 1000000LL + tv->tv_usec;
|
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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user