script hangs while opening a file from /proc in a thread

M

MiG

Hello,
I have a problem with opening a file under /proc in a thread.

This works fine:
File.open('/proc/locks').readlines

But this hangs on open:
t =3D Thread.new { File.open('/proc/locks').readlines }
t.join

It happens on Linux 2.6, Linux 2.4 seems ok.

It looks the same as
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-core/3798

Is there any workaround (other than `cat`) ?

Thank you,
jan molic
 
T

Tanaka Akira

MiG said:
I have a problem with opening a file under /proc in a thread.

This works fine:
File.open('/proc/locks').readlines

But this hangs on open:
t = Thread.new { File.open('/proc/locks').readlines }
t.join

It happens on Linux 2.6, Linux 2.4 seems ok.

It looks the same as
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-core/3798

Is there any workaround (other than `cat`) ?

Upgrade the Linux kernel to 2.6.13.

http://kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.13

| commit e334016fc1735e491385e14157a0360cd85c321b
| Author: Luke Kosewski <[email protected]>
| Date: Wed Jun 1 02:39:28 2005 -0500
|
| Input: do not corrupt system-wide procfs fops.
|
| entry->proc_fops is a pointer to struct file_operations. When we
| call create_proc_entry(...), it pointis to proc_file_operations,
| deep in fs/proc/generic.c. By adding a 'poll' member to this struct
| we effectively force the 'poll' member on every file in /proc,
| which is wrong (they all fail select(...) calls).
|
| This patch changes a copy of entry->proc_fops and reassigns it rather
| than changing the original member.
|
| Signed-off-by: Dmitry Torokhov <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top