childprocess 0.3.1 → 0.3.2

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.
data/lib/childprocess.rb CHANGED
@@ -8,6 +8,8 @@ module ChildProcess
8
8
  autoload :Windows, 'childprocess/windows'
9
9
  autoload :JRuby, 'childprocess/jruby'
10
10
 
11
+ @posix_spawn = false
12
+
11
13
  class << self
12
14
  def new(*args)
13
15
  case os
@@ -57,8 +59,6 @@ module ChildProcess
57
59
  os == :windows
58
60
  end
59
61
 
60
- @posix_spawn = false
61
-
62
62
  def posix_spawn?
63
63
  enabled = @posix_spawn || %w[1 true].include?(ENV['CHILDPROCESS_POSIX_SPAWN'])
64
64
  return false unless enabled
@@ -143,6 +143,13 @@ module ChildProcess
143
143
  file.close_on_exec = true
144
144
  elsif file.respond_to?(:fcntl) && defined?(Fcntl::FD_CLOEXEC)
145
145
  file.fcntl Fcntl::F_SETFD, Fcntl::FD_CLOEXEC
146
+
147
+ if jruby? && posix_spawn?
148
+ # on JRuby, the fcntl call above apparently isn't enough when
149
+ # we're launching the process through posix_spawn.
150
+ fileno = JRuby.posix_fileno_for(file)
151
+ Unix::Lib.fcntl fileno, Fcntl::F_SETFD, Fcntl::FD_CLOEXEC
152
+ end
146
153
  elsif windows?
147
154
  Windows::Lib.dont_inherit file
148
155
  else
@@ -1,14 +1,21 @@
1
1
  module ChildProcess
2
- class Error < StandardError; end
3
- class TimeoutError < StandardError; end
4
- class SubclassResponsibility < StandardError; end
5
- class InvalidEnvironmentVariable < StandardError; end
6
- class LaunchError < StandardError; end
2
+ class Error < StandardError
3
+ end
7
4
 
8
- class MissingPlatformError < StandardError
9
- def initialize
10
- platform = ChildProcess.platform_name
5
+ class TimeoutError < Error
6
+ end
7
+
8
+ class SubclassResponsibility < Error
9
+ end
11
10
 
11
+ class InvalidEnvironmentVariable < Error
12
+ end
13
+
14
+ class LaunchError < Error
15
+ end
16
+
17
+ class MissingPlatformError < Error
18
+ def initialize
12
19
  message = "posix_spawn is not yet supported on #{ChildProcess.platform_name} (#{RUBY_PLATFORM}), falling back to default implementation. " +
13
20
  "If you believe this is an error, please file a bug at http://github.com/jarib/childprocess/issues"
14
21
 
@@ -1,4 +1,3 @@
1
-
2
1
  module ChildProcess
3
2
  module Unix
4
3
  module Lib
@@ -15,6 +14,8 @@ module ChildProcess
15
14
  end
16
15
 
17
16
  attach_function :strerror, [:int], :string
17
+ attach_function :chdir, [:string], :int
18
+ attach_function :fcntl, [:int, :int, :int], :int # fcntl actually takes varags, but we only need this version.
18
19
 
19
20
  # int posix_spawnp(
20
21
  # pid_t *restrict pid,
@@ -41,6 +41,13 @@ module ChildProcess
41
41
  argv = Argv.new(@args)
42
42
  envp = Envp.new(ENV.to_hash.merge(@environment))
43
43
 
44
+ if ChildProcess.jruby?
45
+ # on JRuby, the current working directory is for some reason not inherited.
46
+ # We'll work around it by making a chdir call through FFI.
47
+ # TODO: report this to JRuby
48
+ Lib.chdir Dir.pwd
49
+ end
50
+
44
51
  ret = Lib.posix_spawnp(
45
52
  pid_ptr,
46
53
  @args.first, # TODO: not sure this matches exec() behaviour
@@ -30,6 +30,7 @@ module ChildProcess
30
30
 
31
31
  assert_started
32
32
  pid, status = ::Process.waitpid2(@pid, ::Process::WNOHANG)
33
+ pid = nil if pid == 0 # may happen on jruby
33
34
 
34
35
  log(:pid => pid, :status => status)
35
36
 
@@ -1,3 +1,3 @@
1
1
  module ChildProcess
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,94 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: childprocess
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jari Bakken
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-02-05 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-04-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 15
29
- segments:
30
- - 2
31
- - 0
32
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 2.0.0
34
22
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: yard
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: yard
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
48
38
  type: :development
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: rake
52
39
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
54
49
  none: false
55
- requirements:
50
+ requirements:
56
51
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 63
59
- segments:
60
- - 0
61
- - 9
62
- - 2
52
+ - !ruby/object:Gem::Version
63
53
  version: 0.9.2
64
54
  type: :development
65
- version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- name: ffi
68
55
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
70
57
  none: false
71
- requirements:
58
+ requirements:
72
59
  - - ~>
73
- - !ruby/object:Gem::Version
74
- hash: 27
75
- segments:
76
- - 1
77
- - 0
78
- - 6
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: ffi
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
79
69
  version: 1.0.6
80
70
  type: :runtime
81
- version_requirements: *id004
82
- description: This gem aims at being a simple and reliable solution for controlling external programs running in the background on any Ruby / OS combination.
83
- email:
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.0.6
78
+ description: This gem aims at being a simple and reliable solution for controlling
79
+ external programs running in the background on any Ruby / OS combination.
80
+ email:
84
81
  - jari.bakken@gmail.com
85
82
  executables: []
86
-
87
83
  extensions: []
88
-
89
84
  extra_rdoc_files: []
90
-
91
- files:
85
+ files:
92
86
  - .document
93
87
  - .gitignore
94
88
  - .rspec
@@ -135,38 +129,30 @@ files:
135
129
  - spec/windows_spec.rb
136
130
  homepage: http://github.com/jarib/childprocess
137
131
  licenses: []
138
-
139
132
  post_install_message:
140
133
  rdoc_options: []
141
-
142
- require_paths:
134
+ require_paths:
143
135
  - lib
144
- required_ruby_version: !ruby/object:Gem::Requirement
136
+ required_ruby_version: !ruby/object:Gem::Requirement
145
137
  none: false
146
- requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- hash: 3
150
- segments:
151
- - 0
152
- version: "0"
153
- required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
143
  none: false
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- hash: 3
159
- segments:
160
- - 0
161
- version: "0"
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
162
148
  requirements: []
163
-
164
149
  rubyforge_project: childprocess
165
- rubygems_version: 1.8.15
150
+ rubygems_version: 1.8.21
166
151
  signing_key:
167
152
  specification_version: 3
168
- summary: This gem aims at being a simple and reliable solution for controlling external programs running in the background on any Ruby / OS combination.
169
- test_files:
153
+ summary: This gem aims at being a simple and reliable solution for controlling external
154
+ programs running in the background on any Ruby / OS combination.
155
+ test_files:
170
156
  - spec/abstract_io_spec.rb
171
157
  - spec/childprocess_spec.rb
172
158
  - spec/io_spec.rb