trident 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDdmMDA1Y2YzMDI4YzcyM2VkZDIyNmNjZTViYzVjZWJiZDAyNzE1Yw==
4
+ NWVkOTkzYzA0Y2Y4NGJjODIzZWI2ZjJmNzExOWQ3YWUyN2I3ZDQ2OA==
5
5
  data.tar.gz: !binary |-
6
- NDUxYTk3ZGE5ZTRjZWNhZDVkMmEwYWY4Yjg5NTFhOTBiYWQyMjg4Ng==
6
+ YThjMjE1Y2Q4MWM1YWRiMDI4ZWU1N2ViNzMzNjg2NWNmM2FiMjdhZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWRhNzgzNzY4ODZkZDZjZGU1ZmZlMzQxMTA5ZGFmNDUyMjA4Yjc4YzMxNmFm
10
- OTg4Y2VkNTdkZjU0MmM2ODc1NjRhNjM3ZWJiOWZiN2EzMzc2NDY0ZWU3NmY3
11
- MjYxYmY5YWQ4ZjZjY2Y2M2MzNjA1OWFkNGJiNTI1MGU4ZDlkYTY=
9
+ OWNjOTRiYWE4YTUxMmI0ZWQ0MWZhOWEyMjc0ZWM5YTgzMGYxMmRjYTM3ODI3
10
+ MDU4ZWZiMDY0Mzc5ZTRlMTk0ZTBiN2MwZDI0YThhZjY5MjgwZDJkMGMxNDU5
11
+ ZTU0NDlmMDVkMzc1OGEwOTFmMjFlMDMxZDBmODk1NWI5OTJhMTc=
12
12
  data.tar.gz: !binary |-
13
- ZjE0YzhiYzU0OWRjN2M3NTE0ZmIyMzBiNmJiNzI2ZGM2ODk2NjVjZjRlZDAy
14
- MjEwNTc5MmQ2ZWVkNTdiNWYyYTRmYzEyNzcyMmY4YWFkNTMxMjliZTc3ZTQ3
15
- MjZkZjFlOWQ0MzZhZWI5NWQ3NjUyMTdkYTZiMzMyYTE5M2QwZmU=
13
+ M2E4NTFmOTc2OWFlNzg2YWZmMGY4YmViODExNGQyYmEwODNlMzY2MjgyNjlh
14
+ ODI5Y2IyZmIzNTg0M2ZkMzQyOWE4NjZkN2UwMjY2NWNjMmE2MzZlZDI0NjRm
15
+ MDc1NmYzOGYxNTU1MGIzYzJlY2MwNmVhYWZlNzBkM2NiZTliNjM=
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 0.4.0 (11/19/2013)
2
+ ------------------
3
+
4
+ don't implicitly set SIGCHLD, and reset back to default when appropriate <5a4f774> [Matt Conway]
5
+
1
6
  0.3.0 (11/19/2013)
2
7
  ------------------
3
8
 
@@ -118,10 +118,6 @@ module Trident
118
118
 
119
119
  @signal_mappings[k] = Array(v)
120
120
  end
121
-
122
- # Should always handle CHLD signals as they wakeup/drive the main
123
- # loop on status changes from child processes
124
- @signal_mappings = {"SIGCHLD" => ["update"]}.merge(@signal_mappings)
125
121
  end
126
122
 
127
123
  def setup_self_pipe
@@ -143,7 +139,13 @@ module Trident
143
139
 
144
140
  def reset_signal_handlers
145
141
  original_signal_handlers.each do |signal_name, original_handler|
146
- trap(signal_name, original_handler)
142
+ if signal_name == "SIGCHLD" && original_handler == nil
143
+ # SIGCHLD handler needs to be default for stuff like
144
+ # Process.detach to work correctly
145
+ trap(signal_name, "DEFAULT")
146
+ else
147
+ trap(signal_name, original_handler)
148
+ end
147
149
  end
148
150
  original_signal_handlers.clear
149
151
  end
@@ -1,3 +1,3 @@
1
1
  module Trident
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -37,20 +37,6 @@ class Trident::SignalHandlerTest < MiniTest::Should::TestCase
37
37
  Marshal.load(result)
38
38
  end
39
39
 
40
- context "#initialize" do
41
-
42
- should "add in CHLD handler" do
43
- handler = SignalHandler.new({}, Target.new)
44
- assert_equal({"SIGCHLD" => ["update"]}, handler.signal_mappings)
45
- end
46
-
47
- should "allow CHLD handler replacement" do
48
- handler = SignalHandler.new({"CHLD" => "foo"}, Target.new)
49
- assert_equal({"SIGCHLD" => ["foo"]}, handler.signal_mappings)
50
- end
51
-
52
- end
53
-
54
40
  context "#signal_mappings==" do
55
41
 
56
42
  should "normalize signal names" do
@@ -59,7 +45,7 @@ class Trident::SignalHandlerTest < MiniTest::Should::TestCase
59
45
  {"int" => "foo", "sigterm" => "bar",
60
46
  "USR1" => "baz", "SIGUSR2" => ["bum", "hum"]}
61
47
 
62
- assert_equal({"SIGCHLD" => ["update"], "SIGINT" => ["foo"],
48
+ assert_equal({"SIGINT" => ["foo"],
63
49
  "SIGTERM" => ["bar"], "SIGUSR1" => ["baz"],
64
50
  "SIGUSR2" => ["bum", "hum"]}, handler.signal_mappings)
65
51
  end
@@ -102,7 +88,6 @@ class Trident::SignalHandlerTest < MiniTest::Should::TestCase
102
88
 
103
89
  handler.expects(:trap_deferred).with("SIGINT")
104
90
  handler.expects(:trap_deferred).with("SIGTERM")
105
- handler.expects(:trap_deferred).with("SIGCHLD")
106
91
  handler.send(:setup_signal_handlers)
107
92
  end
108
93
 
@@ -112,7 +97,7 @@ class Trident::SignalHandlerTest < MiniTest::Should::TestCase
112
97
 
113
98
  handler.stubs(:trap_deferred)
114
99
  handler.send(:setup_signal_handlers)
115
- assert_equal({"SIGCHLD" => nil, "SIGINT" => nil, "SIGTERM" => nil},
100
+ assert_equal({"SIGINT" => nil, "SIGTERM" => nil},
116
101
  handler.original_signal_handlers)
117
102
  end
118
103
 
@@ -137,11 +122,34 @@ class Trident::SignalHandlerTest < MiniTest::Should::TestCase
137
122
 
138
123
  handler.expects(:trap).with("SIGINT", nil)
139
124
  handler.expects(:trap).with("SIGTERM", nil)
140
- handler.expects(:trap).with("SIGCHLD", nil)
141
125
  handler.send(:reset_signal_handlers)
142
126
  assert_empty handler.original_signal_handlers
143
127
  end
144
128
 
129
+ should "reset SIGCHLD to default" do
130
+ signals = {"chld" => "update"}
131
+ handler = SignalHandler.new(signals, Target.new)
132
+
133
+ handler.stubs(:trap_deferred)
134
+ handler.send(:setup_signal_handlers)
135
+
136
+ handler.expects(:trap).with("SIGCHLD", "DEFAULT")
137
+ handler.send(:reset_signal_handlers)
138
+ assert_empty handler.original_signal_handlers
139
+ end
140
+
141
+ should "reset signals to original when set" do
142
+ signals = {"int" => "foo", "chld" => "bar"}
143
+ handler = SignalHandler.new(signals, Target.new)
144
+
145
+ handler.stubs(:trap_deferred).returns("IGNORE")
146
+ handler.send(:setup_signal_handlers)
147
+
148
+ handler.expects(:trap).with("SIGINT", "IGNORE")
149
+ handler.expects(:trap).with("SIGCHLD", "IGNORE")
150
+ handler.send(:reset_signal_handlers)
151
+ assert_empty handler.original_signal_handlers
152
+ end
145
153
  end
146
154
 
147
155
  context "#handle_signal_queue" do
@@ -252,6 +260,25 @@ class Trident::SignalHandlerTest < MiniTest::Should::TestCase
252
260
  assert_equal [[:bar, [], nil], [:foo, [], nil], [:action_break, [], nil]], received
253
261
  end
254
262
 
263
+ should "preserve SIGCHLD behavior" do
264
+ fc1 = ForkChild.new do
265
+ target = Target.new
266
+ SignalHandler.start({"chld" => "foo"}, target)
267
+ fc2 = ForkChild.new do
268
+ SignalHandler.reset_for_fork
269
+ pid = fork do
270
+ sleep 0.1
271
+ end
272
+ wait_thr = Process.detach(pid)
273
+ wait_thr.value.nil? # this will be nil if CHLD handler is not "DEFAULT"
274
+ end
275
+ fc2.wait
276
+ end
277
+
278
+ received = fc1.wait
279
+ assert_equal false, received
280
+ end
281
+
255
282
  should "honor signal queue limit" do
256
283
  fc = ForkChild.new do
257
284
  $stderr.reopen("/dev/null")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trident
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway