From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 29 06:01:11 2010 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A34C6106564A for ; Thu, 29 Jul 2010 06:01:11 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 700E38FC08 for ; Thu, 29 Jul 2010 06:01:11 +0000 (UTC) Received: by iwn35 with SMTP id 35so300960iwn.13 for ; Wed, 28 Jul 2010 23:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=ylIhYcZE9IGSSLxwskrRAXRMkjbc9szOSqHUOoj3veE=; b=haUdb5OR5IQY/16R9uFEF6Nhxq8Qw1CulRZJYPA0n/Va2dgZHtS/EuKYSbLrEfIDZl X4nXClzqsI/edHxdrIaFVhZcx24JuXW+h12j35UE1s5zdsmsmFealQXUjOJvfXmDnO6n aVvCoL6XngSmVwIgmWTzChZBeMGETarKWjmyk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=PSKZGLdLIs6OOs0C/PHXPRRhRs7FUmOaLPSBYLeF1S0Nku8HT7GUgX9FywtpO9Ezuf aUD3dqt0kJz3GuM4Zr/hqtTi+gydkhDOStDX2bKY+e38MTmHD3+1VbzcC6OAcUKqaHmo qhtPcAoanQEc6s8GVVIy0pK+MKphBGPy49Xww= MIME-Version: 1.0 Received: by 10.231.59.13 with SMTP id j13mr13391175ibh.77.1280383270838; Wed, 28 Jul 2010 23:01:10 -0700 (PDT) Received: by 10.231.169.18 with HTTP; Wed, 28 Jul 2010 23:01:10 -0700 (PDT) Date: Wed, 28 Jul 2010 23:01:10 -0700 Message-ID: From: Garrett Cooper To: hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Cc: Subject: nanosleep - does it make sense with tv_sec < 0? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jul 2010 06:01:11 -0000 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