From boris@cs.tu-berlin.de  Thu Nov 14 05:39:21 2002
Return-Path: <boris@cs.tu-berlin.de>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1E48A37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 14 Nov 2002 05:39:21 -0800 (PST)
Received: from mail.cs.tu-berlin.de (mail.cs.tu-berlin.de [130.149.17.13])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 835AB43E6E
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 14 Nov 2002 05:39:16 -0800 (PST)
	(envelope-from boris@cs.tu-berlin.de)
Received: from fiesta.cs.tu-berlin.de (daemon@fiesta.cs.tu-berlin.de [130.149.17.4])
	by mail.cs.tu-berlin.de (8.9.3/8.9.3) with ESMTP id OAA12356
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 14 Nov 2002 14:33:54 +0100 (MET)
Received: (from boris@localhost)
	by fiesta.cs.tu-berlin.de (8.11.6+Sun/8.9.3) id gAEDXsx15017
	for FreeBSD-gnats-submit@freebsd.org; Thu, 14 Nov 2002 14:33:54 +0100 (MET)
Message-Id: <20021114133354.GA13558@fiesta.cs.tu-berlin.de>
Date: Thu, 14 Nov 2002 14:33:54 +0100
From: Boris Nikolaus <boris@cs.tu-berlin.de>
Reply-To: Boris Nikolaus <boris@cs.tu-berlin.de>
To: FreeBSD-gnats-submit@freebsd.org
Subject: kevent(2) ignores timeout if nevents == 0
X-Send-Pr-Version: 3.113

>Number:         45291
>Category:       kern
>Synopsis:       kevent(2) ignores timeout if nevents == 0
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jmg
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 14 05:40:01 PST 2002
>Closed-Date:    Sun Oct 19 18:51:06 PDT 2003
>Last-Modified:  Sun Oct 19 18:51:06 PDT 2003
>Originator:     Boris Nikolaus
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
>Environment:
System: FreeBSD XXXXX 4.7-STABLE FreeBSD 4.7-STABLE #43: Tue Oct 22 20:25:44 CEST 2002     root@XXXXXX:/usr/src/sys/compile/BORIS  i386
>Description:
kevent(2) returns immediatly (ignoring the given timeout) if the "nevents"
parameter is 0. I would expect that it sleeps the time (similar to
poll(2)/select(2)).
>How-To-Repeat:
This program terminates immediately instead of sleeping for 10 seconds:

#include <stdio.h>
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>

int main() {
    int qfd;
    struct timespec ts;
    int ret;

    qfd = kqueue();
    ts.tv_sec = 10;
    ts.tv_nsec = 0;
    ret = kevent(qfd, NULL, 0, NULL, 0, &ts);
    printf("kevent returned %d\n", ret);

    return 0;
}
>Fix:
Problem can be circumvented by calling "nanosleep(&ts, NULL)" if the nevents
parameter would be 0.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: jmg 
State-Changed-When: Mon Oct 13 00:46:53 PDT 2003 
State-Changed-Why:  
to quote the man page: If timeout is a non-NULL pointer, it specifies 
a maximum interval to wait for an event, 

The behavior is correct since you wanted to wait for 0 events, and since 
it has delivered all the events it can (none), it returns.  Unless provide 
with good reason (or maybe a patch to the manpage to document this feature?) 
I will close the PR in 5 days. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=45291 
Responsible-Changed-From-To: freebsd-bugs->jmg 
Responsible-Changed-By: jmg 
Responsible-Changed-When: Mon Oct 13 00:49:38 PDT 2003 
Responsible-Changed-Why:  
need to take ownership of this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=45291 
State-Changed-From-To: feedback->closed 
State-Changed-By: jmg 
State-Changed-When: Sun Oct 19 18:49:04 PDT 2003 
State-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=45291 
>Unformatted:
