Subject: setting O_NONBLOCK on /dev/null
To: None <current-users@netbsd.org>
From: Dan <kasper37@netzero.com>
List: current-users
Date: 02/26/2002 09:58:03
I'm not an expert on the use of fcntl, but this issue was brought up on the
courier-mta list that I'm on and thought that I would relay it here.  I'll let
the code do the talking:

This is the result on my NetBSD 1.5ZA system:

~ $ cat >mytest.c <<EOF
> #include <stdio.h>
> #include <fcntl.h>
> int main(void)
> {
>         fprintf(stderr,"%d\n",fcntl(0, F_SETFL, O_NONBLOCK));
>         fprintf(stderr,"%d\n",fcntl(1, F_SETFL, O_NONBLOCK));
>         return 0;
> }
> EOF
~ $ gcc -Wall -o mytest mytest.c
~ $ ./mytest
0
0
~ $ ./mytest >/dev/null
0
-1
~ $

and this is the resuly on my Linux 2.2.19 system:

[kasper37@localhost kasper37]$ cat >mytest.c <<EOF
> #include <stdio.h>
> #include <fcntl.h>
> int main(void)
> {
>         fprintf(stderr,"%d\n",fcntl(0, F_SETFL, O_NONBLOCK));
>         fprintf(stderr,"%d\n",fcntl(1, F_SETFL, O_NONBLOCK));
>         return 0;
> }
> EOF
[kasper37@localhost kasper37]$ gcc -Wall -o mytest mytest.c
[kasper37@localhost kasper37]$ ./mytest
0
0
[kasper37@localhost kasper37]$ ./mytest >/dev/null
0
0
[kasper37@localhost kasper37]$

Dan