diff --git a/src/system/libroot/posix/sys/select.c b/src/system/libroot/posix/sys/select.c index fa293b9967..410cc54eab 100644 --- a/src/system/libroot/posix/sys/select.c +++ b/src/system/libroot/posix/sys/select.c @@ -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 #include #include +#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); +}