How to gracefully kill IRB


leaving aside our RubyGUI debate for while, I have a question about IRB.

The script i have currently in dev. ends with this:
When I close the GUI (an action calling "Tk::exit; exit(0)" ) , the
shell invoking the script
remains in an inconsistent state, i type and i get nothing printed into
it. I must kill it.
(i am running the thing in FreeBSD, lanunching my script from a Konsole)

Is there a way i can terminate IRB REPL
without doing Ctrl-d or Ctrl-d from the REPL itself, without loosing the
invoking shell ?



Re: How to gracefully kill IRB

By Hassan Schroeder at 08/07/2018 - 10:35

07:32 ~/testcases/ruby: [ex:1.7.2 Erlang/OTP 21][ruby-2.5.1@testcase]$ irb
2.5.1 :001 > methods
=> [:conf, :kill, :exit, :context, :inspect, :irb_quit, :quit,
:irb_print_working_workspace, :irb_cwws, :irb_pwws, :cwws, :pwws,
:irb_current_working_binding, :irb_print_working_binding, :irb_cwb,
:irb_pwb, :irb_chws, :irb_cws, :chws, :cws, :to_s, :irb_cb, :cb,
:irb_change_binding, :workspaces, :irb_bindings, :bindings,
:irb_pushws, :pushws, :irb_push_binding, :irb_pushb, :pushb,
:irb_popws, :popws, :irb_pop_binding, :irb_popb, :popb, :jobs, :fg,
:source, :help, :irb_load, :irb_require, :irb_change_workspace,
:irb_source, :irb_jobs, :irb_fg, :irb_kill, :irb_workspaces,
:irb_help, :irb_push_workspace, :irb_context, :irb_exit,
:install_alias_method, :irb_current_working_workspace,
:irb_pop_workspace, :irb, :instance_variable_set,
:instance_variable_defined?, :remove_instance_variable, :instance_of?,
:kind_of?, :is_a?, :tap, :instance_variable_get, :public_methods,
:instance_variables, :method, :public_method,
:define_singleton_method, :singleton_method, :public_send, :extend,
:pp, :to_enum, :enum_for, :<=>, :===, :=~, :!~, :eql?, :respond_to?,
:freeze, :object_id, :send, :display, :nil?, :hash, :class,
:singleton_class, :clone, :dup, :yield_self, :itself, :tainted?,
:taint, :untrust, :untaint, :trust, :untrusted?, :methods, :frozen?,
:singleton_methods, :protected_methods, :private_methods, :!, :equal?,
:instance_eval, :==, :instance_exec, :!=, :__id__, :__send__]
2.5.1 :002 > exit
07:34 ~/testcases/ruby: [ex:1.7.2 Erlang/OTP 21][ruby-2.5.1@testcase]$


Re: How to gracefully kill IRB

By Nicola Mingotti at 08/07/2018 - 11:08

Hassan, thanks, but maybe i did not explain well the problem.

So, i will write a runnable snippet as soon as possible to show the
and post it here.


On 08/07/18 16:35, Hassan Schroeder wrote:

Re: How to gracefully kill IRB

By Nicola Mingotti at 08/07/2018 - 12:12

ok, here is the demo code,
1] run the script from a terminal (i tried in Konsole and xterm)
2] use the "Quit" button to end the demo
==> The terminal "hangs", I write the I see almost nothing.

I suppose it is because IRB REPL was not shutdonw properly and it
has mangled the tty.

I can get the terminal back working properly if i give command "stty sane".

---------------- demo.rb ------------------
require 'tk'
require 'irb'

root = { title "Demo" }
b = do
  text "Quit";
  command proc { Tk::exit; exit(0); }

t1 = { Tk.mainloop; }

On 08/07/18 17:08, Nicola Mingotti wrote: