/dev/null doesn't do the right thing with select??

/dev/null doesn't do the right thing with select??

Post by Cliff Lass » Wed, 24 May 1995 04:00:00



In linux version 1.1.47, the select system call on /dev/null always
returns 0 for readfds and writefds.  I'm no Posix wizard, but this
doesn't seem quite right.  Select should return 0 if a read or write
on the fd will block, which of course /dev/null never does.  The fix
in the kernel is obvious.

Has this bug been fixed in a newer version of the kernel?  If not,
who/how does something like this get fixed?  I'm new to this list so
I'm not familiar with whatever procedures happen to be in place.

        -Cliff

 
 
 

/dev/null doesn't do the right thing with select??

Post by Lex Spo » Mon, 29 May 1995 04:00:00




: > In linux version 1.1.47, the select system call on /dev/null always
: > returns 0 for readfds and writefds.  I'm no Posix wizard, but this
: > doesn't seem quite right.  Select should return 0 if a read or write
: > on the fd will block, which of course /dev/null never does.  The fix
: > in the kernel is obvious.
: >
: Actually, I have to say I _like_ this "bug". For instance, I have a process
: which monitors a device; it accepts commands from stdin (including EOF for
: "please shut down"). The fact that select() doesn't return for /dev/null
: means that I don't have to remember to use a "ignore-stdin" flag when I
: want to run this job in the background; instead, I just say </dev/null.

: I agree that the output side of /dev/null should return 1, however.

Hmm, on linux 1.2.8 select seems to return a 1 bit in both readfs
and writefs.  Test program follows.

-Lex

#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <sys/time.h>

main()
{
  int fd;
  fd_set readfs, writefs;
  int result;

  fd  = open("/dev/null", O_RDWR);

  FD_ZERO(&readfs);
  FD_SET(fd, &readfs);
  writefs = readfs;

  printf("before:  %x   %x\n", (int) readfs.fds_bits[0], (int) writefs.fds_bits[0]);

  result = select(255, &readfs, &writefs, NULL, NULL);

  printf("result: %d\n", result);
  printf("after:  %x   %x\n", (int) readfs.fds_bits[0], (int) writefs.fds_bits[0]);

Quote:}

output:

before:  8   8
result: 2
after:  8   8

 
 
 

1. rsh machine -n 'command >&/dev/null </dev/null &'

My copy of the Unix FAQ suggests syntax like this

            rsh machine -n 'command >&/dev/null </dev/null &'

for running rsh (assuming I use csh on the remote machine, and
something similar if I use sh remotely).  This has always worked
fine for me under SunOS 4.1.2.

My question is: Will this magic necessary under Solaris 2.X?

Many thanks!
---
------------------------------------------------------------------
Francois-Michel Lang          (202) 752-6067   FAX: (202) 752-5074


2. Q: dosemu on Viper330 AGP failed

3. TOSS_OUTPUT=' >/dev/null' doesn't work

4. no network in Mandrake 9.0

5. select() works with NULL timeval, doesn't otherwise

6. CD-ROM driver

7. that sun env var thing -- it's the old LD_LIBRARY_PATH thing right?

8. DECT-PCMCIA-cards supported?

9. 'w' & 'who' doesnt display the right thing!

10. HELP: 2>&1 > /dev/null != 2>&- > /dev/null ???

11. cp /dev/null or cat /dev/null

12. select broken on /dev/null?

13. Dev's Dev's Dev's