Thread#kill works as a script but not in irb

D

Deepak Kannan

hi,
Thread#kill works as a script but not in irb
I though that the problem is that irb evals the code. But manually
evaling the code has the same problem.

Code:
t = Thread.new { kill }
puts t.inspect

# irb eval's code. but then this works as a script but does not work in
irb
# eval "t = Thread.new { kill }; puts t.inspect"

Output:
runs successfully when run as a script ie. ruby <filename>
=> #<Thread:0x1dc5090 dead>

But running it on irb gives an error
load '/tmp/baz.rb'
=> #<Thread:0x2813678 dead>
IRB::NoSuchJob: No such job(#<Thread:0x243e278>).
from :0

PS: https://gist.github.com/779402

regards,
deepak
 
J

Jonas Pfenniger (zimbatm)

2011/1/14 Deepak Kannan said:
hi,
Thread#kill works as a script but not in irb
I though that the problem is that irb evals the code. But manually
evaling the code has the same problem.

Code:
t = Thread.new { kill }
puts t.inspect

# irb eval's code. but then this works as a script but does not work in
irb
# eval "t = Thread.new { kill }; puts t.inspect"

Output:
runs successfully when run as a script ie. ruby <filename>
=> #<Thread:0x1dc5090 dead>

But running it on irb gives an error
=> #<Thread:0x2813678 dead>
IRB::NoSuchJob: No such job(#<Thread:0x243e278>).
from :0

PS: https://gist.github.com/779402

regards,
deepak

Yeah it looks like a 1.8 issue. 1.9.2 works fine though.
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top