: > 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.
fd_set readfs, writefs;
fd = open("/dev/null", O_RDWR);
writefs = readfs;
printf("before: %x %x\n", (int) readfs.fds_bits, (int) writefs.fds_bits);
result = select(255, &readfs, &writefs, NULL, NULL);
printf("result: %d\n", result);
printf("after: %x %x\n", (int) readfs.fds_bits, (int) writefs.fds_bits);
before: 8 8
after: 8 8