From: William Morgan Date: 2005-02-21T04:06:22+09:00 Subject: Re: Lock on some special file reading within XML-RPC Excerpts from Pascal Terjan's mail of 20 Feb 2005 (EST): > I was having a timeout in a client/server program using xml-rpc under > Linux. [snip] > [pterjan@cmoi tmp]$ strace -p 12756 > Process 12756 attached - interrupt to quit > select(6, [3 5], [], [], NULL > > If I'm not wrong, 3 is the socket and 5 the file I'm trying to read. > The problem also occurs on some other files in /proc, replacing the read > (any sort of it will fail) by `cat /proc/cmdline` is OK. I guess these > files do not like select... > > The read works fine outside xmlrpc : > > [pterjan@cmoi tmp]$ ruby -e 'puts File.readlines("/proc/cmdline")' > auto BOOT_IMAGE=linux ro root=301 acpi=on resume=/dev/hda6 splash=silent This is a known problem with no solution, only workarounds. xmlrpc uses threads. In threading mode, Ruby uses the select system call rather than read. But in kernel 2.6, many /proc files do not respond to select. For example, the following slight modification of the above hangs indefinitely: ruby -e 'Thread.new { sleep 0 }; puts File.readlines("/proc/cmdline")' To the best of my knowledge, your only option is to say: IO.popen("cat /proc/cmdline") Gory details here: http://www.all-thing.net/Ruby/select_and_procfs.html -- William