Messages in this thread | | | Subject | 2.6 select doesn't notify readablity of /proc/loadavg. | From | Tanaka Akira <> | Date | Fri, 05 Aug 2005 14:47:59 +0900 |
| |
Hi. select in Linux 2.6.12.3 doesn't notify readability of /proc/loadavg and several other files under /proc.
It is reproducible as follows. The sample program follow blocks because select doesn't notify readability.
% uname -a Linux debiansarge 2.6.12.3 #1 Thu Aug 4 20:23:16 JST 2005 i686 GNU/Linux % cat /proc/version Linux version 2.6.12.3 (akr@debiansarge) (gcc version 3.3.5 (Debian 1:3.3.5-13)) #1 Thu Aug 4 20:23:16 JST 2005 % cat t.c #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/select.h>
int main(int argc, char **argv) { int fd, ret; fd_set readfds;
fd = open(argv[1], O_RDONLY); if (fd == -1) { perror("open"); exit(1); }
FD_ZERO(&readfds); FD_SET(fd, &readfds); ret = select(fd+1, &readfds, NULL, NULL, NULL); printf("select returns %d\n", ret); return 0; }
% gcc t.c % ./a.out /proc/loadavg
This program blocks here.
/proc/loadavg can be read by cat.
% ./a.out /proc/loadavg ^C % cat /proc/loadavg 0.00 0.00 0.00 2/36 2597
Also, /proc/cmdline, /proc/devices, /proc/execdomains, /proc/fb, /proc/filesystems, /proc/locks, /proc/meminfo, /proc/uptime and /proc/version are blocks too.
Is this behaviour intentional?
The output of ver_linux is follows.
% sh scripts/ver_linux If some fields are empty or look unusual you may have an old version. Compare to the current minimal requirements in Documentation/Changes. Linux debiansarge 2.6.12.3 #1 Thu Aug 4 20:23:16 JST 2005 i686 GNU/Linux Gnu C 3.3.5 Gnu make 3.80 binutils 2.15 util-linux 2.12p mount 2.12p module-init-tools 3.2-pre1 e2fsprogs 1.37 reiserfsprogs line reiser4progs line nfs-utils 1.0.6 Linux C Library 2.3.2 Dynamic linker (ldd) 2.3.2 Procps 3.2.1 Net-tools 1.60 Console-tools 0.2.3 Sh-utils 5.2.1 Modules Loaded md5 ipv6 evdev ehci_hcd usbcore shpchp pci_hotplug intel_agp piix pcnet32 mii crc32 agpgart ide_disk ide_cd cdrom ide_core rtc unix
Note that select notify readability of /proc/loadavg on Linux 2.4.20.
% uname -a Linux serein 2.4.20-686 #1 Mon Jan 13 22:22:30 EST 2003 i686 GNU/Linux % ./a.out /proc/loadavg select returns 1 -- Tanaka Akira - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |