public
Description: Rubinius, the Ruby VM
Homepage: http://rubini.us
Clone URL: git://github.com/evanphx/rubinius.git
Simplify and move SIGINT handler in kernel/loader.rb
wilson (author)
Thu Jul 10 13:42:52 -0700 2008
commit  a9527f8cb296f4cc8e26c3229bd0155e196692c8
tree    12c32cf853e3946821cf66412ee14fc27ebb3065
parent  b7e52602c3f02a2f21ca9da14646f8b4f0f8a895
...
38
39
40
 
 
 
 
 
 
 
 
 
 
 
 
 
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
...
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
59
60
0
@@ -38,35 +38,23 @@ rescue Object => e
0
   exit 2
0
 end
0
 
0
+# Set up a handler for SIGINT that raises Interrupt on the main thread
0
+Signal.action("INT") do |_|
0
+ thread = Thread.main
0
+
0
+ if thread.alive?
0
+ thread.raise Interrupt, "Thread has been interrupted"
0
+ else # somehow..?
0
+ puts "Signal received, but the main thread is dead."
0
+ puts "Unable to continue."
0
+ exit! 1
0
+ end
0
+end
0
+
0
 # This is the end of the kernel and the beginning of specified
0
 # code. We read out of ARGV to figure out what the user is
0
 # trying to do.
0
 
0
-Signal.action("INT") do |thr|
0
- # We can't raise on ourselves, we raise on main.
0
- if thr == Thread.current
0
- thr = Thread.main
0
- end
0
-
0
- # The current thread might be dead if all other live threads are
0
- # a sleep when the current one died.
0
- unless thr.alive?
0
-
0
- thr = Thread.main
0
- # If main is dead too. Wow. Ok.. well... tell the user.
0
- unless thr.alive?
0
- puts "Signal received, but the main thread is dead."
0
- puts "Unable to continue."
0
- exit! 1
0
- end
0
- end
0
-
0
- # Push the output down a little bit, makes things look more
0
- # obvious that the system was interrupted.
0
- puts
0
- thr.raise Interrupt, "Thread has been interrupted"
0
-end
0
-
0
 # Setup $LOAD_PATH.
0
 
0
 additions = []

Comments

    No one has commented yet.