Changeset 22499

Show
Ignore:
Timestamp:
10/10/07 10:13:34 (14 months ago)
Author:
bonefish
Message:

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/system/libroot/posix/sys/select.c

    r7977 r22499  
    11/*  
    2 ** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 
    3 ** Distributed under the terms of the OpenBeOS License. 
    4 */ 
     2 * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 
     3 * Distributed under the terms of the OpenBeOS License. 
     4 */ 
    55 
    66 
     7#include <errno.h> 
    78#include <sys/select.h> 
    89#include <syscalls.h> 
     10 
     11 
     12#define RETURN_AND_SET_ERRNO(err) \ 
     13        if (err < 0) { \ 
     14                errno = err; \ 
     15                return -1; \ 
     16        } \ 
     17        return err; 
    918 
    1019 
     
    1322        struct fd_set *errorBits, const struct timespec *tv, const sigset_t *sigMask) 
    1423{ 
     24        int status; 
    1525        bigtime_t timeout = -1LL; 
    1626        if (tv) 
    1727                timeout = tv->tv_sec * 1000000LL + tv->tv_nsec / 1000LL; 
    1828 
    19         return _kern_select(numBits, readBits, writeBits, errorBits, timeout, sigMask); 
     29        status = _kern_select(numBits, readBits, writeBits, errorBits, timeout, sigMask); 
     30 
     31        RETURN_AND_SET_ERRNO(status); 
    2032} 
    2133 
     
    2537        struct fd_set *errorBits, struct timeval *tv) 
    2638{ 
     39        int status; 
    2740        bigtime_t timeout = -1LL; 
    2841        if (tv) 
    2942                timeout = tv->tv_sec * 1000000LL + tv->tv_usec; 
    3043 
    31         return _kern_select(numBits, readBits, writeBits, errorBits, timeout, NULL); 
     44        status = _kern_select(numBits, readBits, writeBits, errorBits, timeout, NULL); 
     45 
     46        RETURN_AND_SET_ERRNO(status); 
    3247} 
    33