Hi,
I've stumbled on an edge case where Shoes stepping on the the regular ruby
namespace toes doesn't work:
Shoes has exit method, on of its 'kernel' method can be called simply as
exit.
Ruby Kernel also has exit method, can also be called simply as exit.
of course, in Shoes the Shoes::exit has precedence, so if you need the
Kernel::exit you need to call it from its full name.
Usually this wouldn't matter, has exit does mostly the same thing in Shoes
as it does in Kernel, but here comes the edge case: exit (the Shoes one)
wont't work in forks.
So, if you require an external lib that forks an external process and has an
automatic exit call in its forks to bailout or something, they simply won't
quit, and will stay alive as zombies processes.
example:
START OF CODE
# /////////////////////////////////////////////////
class Shoe < Shoes
url '/', :load
def load
@pid_zombie = fork do
loop do
exit
end
end
@pid_safe = fork do
loop do
Kernel::exit
end
end
layout do
button("Kill #...@pid_zombie.to_s}!!!", :margin => 5) { kill }
end
@title.replace "fork!!"
@display.replace "forks pid: #...@pid_zombie.to_s} should be dead, but
still lives, while fork pid #...@pid_safe.to_s} has already exited, look at
your process monitor (top) to confirm"
end
private
def kill
Process.kill("HUP", @pid_zombie)
end
def layout
background black
stack(:margin => 10) do
@title = title( '',
:align => "center",
:font => "Trebuchet MS",
:stroke => pink
)
end
stack(:margin => 10) do
stack do
@display = para( '',
:size => 14,
:align => "center",
:font => "Trebuchet MS",
:stroke => pink
)
end
yield if block_given?
end
stack(:margin => 10) do
button('quit', :margin => 5) { kill; exit}
end
end
end
Shoes.app :title => 'Zombie Forks!!', :width => 500, :height => 300
# ///////////////////////////////////////////////////////////////
END OF CODE
I just wanted to let you know about my discovery, Its no problem for me but
it may be for others.
L-P