require 'gtk2' Gtk.init w = Gtk::Window.new w.window_position = Gtk::Window::POS_CENTER w.add(b = Gtk::Button.new('foo')) b.signal_connect('clicked') { puts "clicked-1" raise "meuh" puts "clicked-2" } w.show_all begin puts "main-1" Gtk.main puts "main-2" rescue puts "exception: #{$!}" end puts "the end"