From nobody@FreeBSD.org  Fri Sep  4 10:01:27 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4605B106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  4 Sep 2009 10:01:27 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 34BF28FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  4 Sep 2009 10:01:27 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n84A1QlB089796
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 4 Sep 2009 10:01:26 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n84A1QA1089795;
	Fri, 4 Sep 2009 10:01:26 GMT
	(envelope-from nobody)
Message-Id: <200909041001.n84A1QA1089795@www.freebsd.org>
Date: Fri, 4 Sep 2009 10:01:26 GMT
From: Petr Salinger <Petr.Salinger@seznam.cz>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /dev/null does not support nonblocking operation, fcntl(0,F_SETFL,O_NONBLOCK) fails
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         138526
>Category:       kern
>Synopsis:       [null] /dev/null does not support nonblocking operation, fcntl(0,F_SETFL,O_NONBLOCK) fails
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnn
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 04 10:10:05 UTC 2009
>Closed-Date:    Mon May 28 18:46:04 UTC 2012
>Last-Modified:  Mon May 28 18:46:04 UTC 2012
>Originator:     Petr Salinger
>Release:        7.2
>Organization:
>Environment:
>Description:
/dev/null does not support nonblocking operation, 
fcntl(0,F_SETFL,O_NONBLOCK) fails

The testsuite of coreutils 7.5 fails due to this.

It is related also to 
http://www.freebsd.org/cgi/query-pr.cgi?pr=standards/94729

I see no reason, why /dev/null and /dev/zero should operate differently
in blocking and non-blocking mode, it should be sufficient to just ignore
corresponding ioctl/fcntl in kernel.
>How-To-Repeat:

>Fix:
In src/sys/dev/null/null.c
add #include <sys/filio.h>

and into begining of null_ioctl() function

+       if (cmd == FIONBIO)
+               return 0;
+       if ((cmd == FIOASYNC) && ((*(int *)data) == 0))
+               return 0;

May be even 

+       if (cmd == FIONBIO)
+               return 0;
+       if (cmd == FIOASYNC)
+               return 0;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->gnn 
Responsible-Changed-By: gnn 
Responsible-Changed-When: Tue Jan 10 20:01:35 UTC 2012 
Responsible-Changed-Why:  
Take this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138526 
State-Changed-From-To: open->patched 
State-Changed-By: gnn 
State-Changed-When: Wed Jan 11 15:00:45 UTC 2012 
State-Changed-Why:  
Patch applied to HEAD as revision 229965. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138526 
State-Changed-From-To: patched->closed 
State-Changed-By: gnn 
State-Changed-When: Mon May 28 18:45:23 UTC 2012 
State-Changed-Why:  
Closed awaiting feedback on the fix 

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