[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    nanosleep - does it make sense with tv_sec < 0?
From:       Garrett Cooper <yanegomi () gmail ! com>
Date:       2010-07-29 6:01:10
Message-ID: AANLkTinkwvK2tHZ0okZE48bvW8-N4WBOm284fVK2Xi3F () mail ! gmail ! com
[Download RAW message or body]

Hi Hackers,
    I ran into an oddity with the POSIX spec that seems a bit unrealistic:

[EINVAL]
    The rqtp argument specified a nanosecond value less than zero or
greater than or equal to 1000 million.

    Seems like it should also apply for seconds < 0. We current
silently pass this argument in kern/kern_time.c:kern_nanosleep:

int
kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt)
{
        struct timespec ts, ts2, ts3;
        struct timeval tv;
        int error;

        if (rqt->tv_nsec < 0 || rqt->tv_nsec >= 1000000000)
                return (EINVAL);
        if (rqt->tv_sec < 0 || (rqt->tv_sec == 0 && rqt->tv_nsec ==
0)) // <-- first clause here
                return (0);

    but I'm wondering whether or not it makes logical sense for us to
do this (sleep for a negative amount of time?)...
    FWIW Linux returns -1 and sets EINVAL in this case, which makes
more sense to me.
Thanks,
-Garrett
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic