Discussion:
How to gracefully kill IRB
Nicola Mingotti
2018-08-07 13:40:55 UTC
Permalink
Hi,

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

The script i have currently in dev. ends with this:
----
$t_tk = Thread.new { Tk.mainloop; }
IRB.start(__FILE__)
----

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 ?

bye
--
--------------------------
Dr. Nicola Mingotti
R&D - Borghi Srl
CTO - BondInsider
--------------------------
Hassan Schroeder
2018-08-07 14:35:33 UTC
Permalink
Post by Nicola Mingotti
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 ?
07:32 ~/testcases/ruby: [ex:1.7.2 Erlang/OTP 21][ruby-***@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-***@testcase]$

HTH!
--
Hassan Schroeder ------------------------ ***@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

Unsubscribe: <mailto:ruby-talk-***@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
Nicola Mingotti
2018-08-07 15:08:38 UTC
Permalink
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
situation
and post it here.

bye
n.
Post by Hassan Schroeder
Post by Nicola Mingotti
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 ?
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
HTH!
--
--------------------------
Dr. Nicola Mingotti
R&D - Borghi Srl
CTO - BondInsider
--------------------------
Nicola Mingotti
2018-08-07 16:12:19 UTC
Permalink
ok, here is the demo code,
Procedure:
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 = TkRoot.new { title "Demo" }
b = TkButton.new(root) do
  text "Quit";
  command proc { Tk::exit; exit(0); }
  pack
end

t1 = Thread.new { Tk.mainloop; }
IRB.start(__FILE__)
-----------------------------------------------
Post by Nicola Mingotti
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
situation
and post it here.
bye
n.
Post by Hassan Schroeder
Post by Nicola Mingotti
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 ?
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
HTH!
--
--------------------------
Dr. Nicola Mingotti
R&D - Borghi Srl
CTO - BondInsider
--------------------------
--
--------------------------
Dr. Nicola Mingotti
R&D - Borghi Srl
CTO - BondInsider
--------------------------
Loading...