Issue #11060 has been updated by Franck Verrot.


Nobuyoshi Nakada wrote:
> Franck Verrot wrote:
> > I can't reproduce the same errors without correcting the typo (or I'm getting a `NameError: undefined local variable or method ```pi' for main:Object` in the threads).
> 
> It's your typo, not `pi` but `p i`.

My automatic translator tricked me :-)

> > Once running, it seems that loading from a FIFO isn't supported (it's expecting a regular file). Here's a patch for making `load` work with FIFO files.
> 
> It's a different story, please file a new ticket if you think it useful.

Yes it is, so here's the proposal: https://bugs.ruby-lang.org/issues/11273 Thanks!

----------------------------------------
Bug #11060: load(fifo) blocks whole process
https://bugs.ruby-lang.org/issues/11060#change-53259

* Author: Akira Tanaka
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-04-12 trunk 50257) [x86_64-linux]
* Backport: 2.0.0: WONTFIX, 2.1: DONE, 2.2: REQUIRED
----------------------------------------
fifo を load しようとすると、プロセス全体がブロックします。

以下では、0.1 秒毎に表示を行うスレッドを作っていますが、
0.5 秒後に load が呼ばれると表示が途切れます。

```
% mkfifo fifo.rb         
% ls -l fifo.rb                                                                                             
prw-r--r-- 1 akr akr 0 Apr 12 17:13 fifo.rb
% ./ruby -ve 'Thread.new { 0.step {|i| p i; sleep 0.1 } }; sleep 0.5; load "fifo.rb"'
ruby 2.3.0dev (2015-04-12 trunk 50257) [x86_64-linux]
0
1
2
3
4
^C5
-e:1:in `new': Interrupt
	from -e:1:in `load'
	from -e:1:in `<main>'
```

当然、timeout も効きません。

```
% ./ruby -rtimeout -ve 'Thread.new { 0.step {|i| p i; sleep 0.1 } }; sleep 0.5; timeout(1) { load "fifo.rb" }'
ruby 2.3.0dev (2015-04-12 trunk 50257) [x86_64-linux]
0
1
2
3
4
^C5
-e:1:in `new': Interrupt
	from -e:1:in `load'
	from -e:1:in `block in <main>'
	from /home/ruby/tst1/lib/ruby/2.3.0/timeout.rb:89:in `block in timeout'
	from /home/ruby/tst1/lib/ruby/2.3.0/timeout.rb:34:in `block in catch'
	from /home/ruby/tst1/lib/ruby/2.3.0/timeout.rb:34:in `catch'
	from /home/ruby/tst1/lib/ruby/2.3.0/timeout.rb:34:in `catch'
	from /home/ruby/tst1/lib/ruby/2.3.0/timeout.rb:104:in `timeout'
	from /home/ruby/tst1/lib/ruby/2.3.0/timeout.rb:125:in `timeout'
	from -e:1:in `<main>'
```

この挙動をバグと考えるべきかどうかはいまひとつ確信が持てないのですが、
いまのところバグであってもおかしくないと思っています。



---Files--------------------------------
0001-file.c-load-now-supports-reading-from-a-FIFO-file.patch (3.26 KB)


-- 
https://bugs.ruby-lang.org/