exceptional_fork 1.0.0 → 1.1.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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 747654a03842e5bf513885263e928420649bc789
4
- data.tar.gz: 209e893bffed33cf0610551a228f11c1509580f2
3
+ metadata.gz: 1c0f186b58e704eeda7fe96b5fe617927fe9e64e
4
+ data.tar.gz: b44013381bb2431a0d984ac5e9e937385cb65985
5
5
  SHA512:
6
- metadata.gz: 5266e24496d23f343040a1c7fb8820e4513f6162acea0fb1bc9a4fd8a15e3ce8b23d42741a9801e935ab96c320354f0380a369db91f3783569c14d6549eeb17c
7
- data.tar.gz: 1cc0e5f91b46b08dccf7c7870e0551e30dad4eac681af03491e3368ce9484f8c757240061b4a3e52ac45fc587c9497f5aace93441f4ee29d4981121511a350df
6
+ metadata.gz: 1169303635307088336f99794328231245f870013ecf7eb138fe9dd1fb32f197c85e8df1ad1107c1831120a222cfbd8d38cbbd156c3ed4d48c4fdff34c7046e3
7
+ data.tar.gz: 15431a14f4ba784cafdb27940709eb03e4280c86c5d06ce01c83e61dae823f7d97a2390114a7b80fe11dd1b31f71a524c477a198e22d12cbe35e248d61f13d48
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: exceptional_fork 1.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "exceptional_fork"
9
+ s.version = "1.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Julik Tarkhanov"]
14
+ s.date = "2015-12-15"
15
+ s.description = " Uses pipes to re-raise exceptions. Something better than an exit code has to exist. "
16
+ s.email = "me@julik.nl"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "exceptional_fork.gemspec",
29
+ "lib/exceptional_fork.rb",
30
+ "spec/exceptional_fork_spec.rb",
31
+ "spec/spec_helper.rb"
32
+ ]
33
+ s.homepage = "http://github.com/julik/exceptional_fork"
34
+ s.licenses = ["MIT"]
35
+ s.rubygems_version = "2.2.2"
36
+ s.summary = "Raise exceptions from the forked child process in the parent"
37
+
38
+ if s.respond_to? :specification_version then
39
+ s.specification_version = 4
40
+
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_development_dependency(%q<rspec>, ["~> 2.14"])
43
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
44
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
45
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
46
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
47
+ else
48
+ s.add_dependency(%q<rspec>, ["~> 2.14"])
49
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
50
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
51
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
52
+ s.add_dependency(%q<simplecov>, [">= 0"])
53
+ end
54
+ else
55
+ s.add_dependency(%q<rspec>, ["~> 2.14"])
56
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
57
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
59
+ s.add_dependency(%q<simplecov>, [">= 0"])
60
+ end
61
+ end
62
+
@@ -1,5 +1,7 @@
1
1
  module ExceptionalFork
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
+ QUIT = "The child process %d has quit or was killed abruptly. No error information could be retrieved".freeze
4
+ ProcessHung = Class.new(StandardError)
3
5
 
4
6
  # Fork with a block and wait until the forked child exits.
5
7
  # Any exceptions raised within the block will be re-raised from this
@@ -32,6 +34,10 @@ module ExceptionalFork
32
34
  reader.close rescue IOError # Do not leak pipes since the process might be long-lived
33
35
 
34
36
  if $?.exitstatus != 0 # If the process exited uncleanly capture the error
37
+ # If the child gets kill -9d then no exception gets written, and no information
38
+ # gets recovered.
39
+ raise ProcessHung.new(QUIT % pid) if (child_error.nil? || child_error.empty?)
40
+
35
41
  unmarshaled_error, backtrace_in_child = Marshal.load(child_error)
36
42
  # Pick up the exception
37
43
  reconstructed_error = unmarshaled_error.exception
@@ -16,4 +16,19 @@ describe "ExceptionalFork" do
16
16
  expect($1).not_to eq(pid_of_parent.to_s)
17
17
  end
18
18
  end
19
+
20
+ it "raises a ProcessHung if no exception information can be recovered" do
21
+ expect(Process).to receive(:fork).and_call_original
22
+
23
+ pid_of_parent = Process.pid
24
+ begin
25
+ Thread.new { sleep 5; `killall -9 ef-test-process` }
26
+ ExceptionalFork.fork_and_wait { $0 = 'ef-test-process'; sleep 100; }
27
+ expect(false).to eq(true), "This should never be reached"
28
+ rescue => e
29
+ matches = (e.message =~ /No error information could be retrieved/)
30
+ expect(matches).not_to be_nil
31
+ expect($1).not_to eq(pid_of_parent.to_s)
32
+ end
33
+ end
19
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exceptional_fork
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-26 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -95,6 +95,7 @@ files:
95
95
  - LICENSE.txt
96
96
  - README.rdoc
97
97
  - Rakefile
98
+ - exceptional_fork.gemspec
98
99
  - lib/exceptional_fork.rb
99
100
  - spec/exceptional_fork_spec.rb
100
101
  - spec/spec_helper.rb