posix-spawn 0.3.9 → 0.3.10
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 +4 -4
- data/Rakefile +1 -0
- data/ext/extconf.rb +1 -1
- data/lib/posix/spawn.rb +14 -5
- data/lib/posix/spawn/child.rb +1 -1
- data/lib/posix/spawn/version.rb +1 -1
- data/posix-spawn.gemspec +3 -2
- data/test/test_backtick.rb +2 -3
- data/test/test_child.rb +10 -11
- data/test/test_helper.rb +9 -0
- data/test/test_popen.rb +2 -3
- data/test/test_spawn.rb +7 -8
- data/test/test_system.rb +2 -3
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88d9e42c2e091d60ef6bfaa4bee93671bfa7cdf1
|
4
|
+
data.tar.gz: 0c34d4025ca8b876345fea00bb45a152b6909c10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6204dd64bc24a24a7ac155f8f7a0f018860b850b94efc68a68aa6b286a0de3a179deccb6f96ae7b1410045dface4de63aca14d235b1322bfac61399d825b65ff
|
7
|
+
data.tar.gz: 988a0574b69a3accddfbb739c89b3da9949146cf7f316f41e2dc364c4ef5bb3cf7ae69858fe9c0318336e946cfc929a1c77178287e742db5a820044f4d680eee
|
data/Rakefile
CHANGED
data/ext/extconf.rb
CHANGED
data/lib/posix/spawn.rb
CHANGED
@@ -212,8 +212,10 @@ module POSIX
|
|
212
212
|
if fd?(val)
|
213
213
|
val = fd_to_io(val)
|
214
214
|
key.reopen(val)
|
215
|
-
key.close_on_exec
|
216
|
-
|
215
|
+
if key.respond_to?(:close_on_exec=)
|
216
|
+
key.close_on_exec = false
|
217
|
+
val.close_on_exec = false
|
218
|
+
end
|
217
219
|
elsif val == :close
|
218
220
|
if key.respond_to?(:close_on_exec=)
|
219
221
|
key.close_on_exec = true
|
@@ -240,7 +242,12 @@ module POSIX
|
|
240
242
|
Process::setpgid(0, pgroup) if pgroup
|
241
243
|
|
242
244
|
# do the deed
|
243
|
-
|
245
|
+
if RUBY_VERSION =~ /\A1\.8/
|
246
|
+
::Kernel::exec(*argv)
|
247
|
+
else
|
248
|
+
argv_and_options = argv + [{:close_others=>false}]
|
249
|
+
::Kernel::exec(*argv_and_options)
|
250
|
+
end
|
244
251
|
ensure
|
245
252
|
exit!(127)
|
246
253
|
end
|
@@ -271,7 +278,8 @@ module POSIX
|
|
271
278
|
# Returns the String output of the command.
|
272
279
|
def `(cmd)
|
273
280
|
r, w = IO.pipe
|
274
|
-
|
281
|
+
command_and_args = system_command_prefixes + [cmd, {:out => w, r => :close}]
|
282
|
+
pid = spawn(*command_and_args)
|
275
283
|
|
276
284
|
if pid > 0
|
277
285
|
w.close
|
@@ -523,7 +531,8 @@ module POSIX
|
|
523
531
|
def adjust_process_spawn_argv(args)
|
524
532
|
if args.size == 1 && args[0] =~ /[ |>]/
|
525
533
|
# single string with these characters means run it through the shell
|
526
|
-
|
534
|
+
command_and_args = system_command_prefixes + [args[0]]
|
535
|
+
[*command_and_args]
|
527
536
|
elsif !args[0].respond_to?(:to_ary)
|
528
537
|
# [argv0, argv1, ...]
|
529
538
|
[[args[0], args[0]], *args[1..-1]]
|
data/lib/posix/spawn/child.rb
CHANGED
data/lib/posix/spawn/version.rb
CHANGED
data/posix-spawn.gemspec
CHANGED
@@ -7,13 +7,14 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.summary = 'posix_spawnp(2) for ruby'
|
8
8
|
s.description = 'posix-spawn uses posix_spawnp(2) for faster process spawning'
|
9
9
|
|
10
|
-
s.homepage = '
|
10
|
+
s.homepage = 'https://github.com/rtomayko/posix-spawn'
|
11
11
|
|
12
12
|
s.authors = ['Ryan Tomayko', 'Aman Gupta']
|
13
13
|
s.email = ['r@tomayko.com', 'aman@tmm1.net']
|
14
|
-
s.
|
14
|
+
s.licenses = ['MIT', 'LGPL']
|
15
15
|
|
16
16
|
s.add_development_dependency 'rake-compiler', '0.7.6'
|
17
|
+
s.add_development_dependency 'minitest', '>= 4'
|
17
18
|
|
18
19
|
s.extensions = ['ext/extconf.rb']
|
19
20
|
s.executables << 'posix-spawn-benchmark'
|
data/test/test_backtick.rb
CHANGED
data/test/test_child.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# coding: UTF-8
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'posix-spawn'
|
3
|
+
require 'test_helper'
|
5
4
|
|
6
|
-
class ChildTest < Test
|
5
|
+
class ChildTest < Minitest::Test
|
7
6
|
include POSIX::Spawn
|
8
7
|
|
9
8
|
def test_sanity
|
@@ -57,19 +56,19 @@ class ChildTest < Test::Unit::TestCase
|
|
57
56
|
end
|
58
57
|
|
59
58
|
def test_max
|
60
|
-
|
59
|
+
assert_raises MaximumOutputExceeded do
|
61
60
|
Child.new('yes', :max => 100_000)
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
65
64
|
def test_max_with_child_hierarchy
|
66
|
-
|
65
|
+
assert_raises MaximumOutputExceeded do
|
67
66
|
Child.new('/bin/sh', '-c', 'yes', :max => 100_000)
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
71
70
|
def test_max_with_stubborn_child
|
72
|
-
|
71
|
+
assert_raises MaximumOutputExceeded do
|
73
72
|
Child.new("trap '' TERM; yes", :max => 100_000)
|
74
73
|
end
|
75
74
|
end
|
@@ -77,7 +76,7 @@ class ChildTest < Test::Unit::TestCase
|
|
77
76
|
def test_max_with_partial_output
|
78
77
|
p = Child.build('yes', :max => 100_000)
|
79
78
|
assert_nil p.out
|
80
|
-
|
79
|
+
assert_raises MaximumOutputExceeded do
|
81
80
|
p.exec!
|
82
81
|
end
|
83
82
|
assert_output_exceeds_repeated_string("y\n", 100_000, p.out)
|
@@ -85,7 +84,7 @@ class ChildTest < Test::Unit::TestCase
|
|
85
84
|
|
86
85
|
def test_max_with_partial_output_long_lines
|
87
86
|
p = Child.build('yes', "nice to meet you", :max => 10_000)
|
88
|
-
|
87
|
+
assert_raises MaximumOutputExceeded do
|
89
88
|
p.exec!
|
90
89
|
end
|
91
90
|
assert_output_exceeds_repeated_string("nice to meet you\n", 10_000, p.out)
|
@@ -93,14 +92,14 @@ class ChildTest < Test::Unit::TestCase
|
|
93
92
|
|
94
93
|
def test_timeout
|
95
94
|
start = Time.now
|
96
|
-
|
95
|
+
assert_raises TimeoutExceeded do
|
97
96
|
Child.new('sleep', '1', :timeout => 0.05)
|
98
97
|
end
|
99
98
|
assert (Time.now-start) <= 0.2
|
100
99
|
end
|
101
100
|
|
102
101
|
def test_timeout_with_child_hierarchy
|
103
|
-
|
102
|
+
assert_raises TimeoutExceeded do
|
104
103
|
Child.new('/bin/sh', '-c', 'sleep 1', :timeout => 0.05)
|
105
104
|
end
|
106
105
|
end
|
@@ -108,7 +107,7 @@ class ChildTest < Test::Unit::TestCase
|
|
108
107
|
def test_timeout_with_partial_output
|
109
108
|
start = Time.now
|
110
109
|
p = Child.build('echo Hello; sleep 1', :timeout => 0.05)
|
111
|
-
|
110
|
+
assert_raises TimeoutExceeded do
|
112
111
|
p.exec!
|
113
112
|
end
|
114
113
|
assert (Time.now-start) <= 0.2
|
data/test/test_helper.rb
ADDED
data/test/test_popen.rb
CHANGED
data/test/test_spawn.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'posix-spawn'
|
1
|
+
require 'test_helper'
|
3
2
|
|
4
3
|
module SpawnImplementationTests
|
5
4
|
def test_spawn_simple
|
@@ -23,7 +22,7 @@ module SpawnImplementationTests
|
|
23
22
|
end
|
24
23
|
|
25
24
|
def test_spawn_with_invalid_argv
|
26
|
-
|
25
|
+
assert_raises ArgumentError do
|
27
26
|
_spawn(['echo','b','c','d'])
|
28
27
|
end
|
29
28
|
end
|
@@ -314,7 +313,7 @@ module SpawnImplementationTests
|
|
314
313
|
def test_spawn_raises_exception_on_unsupported_options
|
315
314
|
exception = nil
|
316
315
|
|
317
|
-
|
316
|
+
assert_raises ArgumentError do
|
318
317
|
begin
|
319
318
|
_spawn('echo howdy', :out => '/dev/null', :oops => 'blaahh')
|
320
319
|
rescue Exception => e
|
@@ -341,7 +340,7 @@ module SpawnImplementationTests
|
|
341
340
|
end
|
342
341
|
end
|
343
342
|
|
344
|
-
class SpawnTest < Test
|
343
|
+
class SpawnTest < Minitest::Test
|
345
344
|
include POSIX::Spawn
|
346
345
|
|
347
346
|
def test_spawn_methods_exposed_at_module_level
|
@@ -375,14 +374,14 @@ class SpawnTest < Test::Unit::TestCase
|
|
375
374
|
end
|
376
375
|
end
|
377
376
|
|
378
|
-
class PosixSpawnTest < Test
|
377
|
+
class PosixSpawnTest < Minitest::Test
|
379
378
|
include SpawnImplementationTests
|
380
379
|
def _spawn(*argv)
|
381
380
|
POSIX::Spawn.pspawn(*argv)
|
382
381
|
end
|
383
382
|
end
|
384
383
|
|
385
|
-
class ForkSpawnTest < Test
|
384
|
+
class ForkSpawnTest < Minitest::Test
|
386
385
|
include SpawnImplementationTests
|
387
386
|
def _spawn(*argv)
|
388
387
|
POSIX::Spawn.fspawn(*argv)
|
@@ -390,7 +389,7 @@ class ForkSpawnTest < Test::Unit::TestCase
|
|
390
389
|
end
|
391
390
|
|
392
391
|
if ::Process::respond_to?(:spawn)
|
393
|
-
class NativeSpawnTest < Test
|
392
|
+
class NativeSpawnTest < Minitest::Test
|
394
393
|
include SpawnImplementationTests
|
395
394
|
def _spawn(*argv)
|
396
395
|
::Process.spawn(*argv)
|
data/test/test_system.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: posix-spawn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.7.6
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: minitest
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '4'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '4'
|
28
42
|
description: posix-spawn uses posix_spawnp(2) for faster process spawning
|
29
43
|
email:
|
30
44
|
- r@tomayko.com
|
@@ -54,12 +68,14 @@ files:
|
|
54
68
|
- posix-spawn.gemspec
|
55
69
|
- test/test_backtick.rb
|
56
70
|
- test/test_child.rb
|
71
|
+
- test/test_helper.rb
|
57
72
|
- test/test_popen.rb
|
58
73
|
- test/test_spawn.rb
|
59
74
|
- test/test_system.rb
|
60
|
-
homepage:
|
75
|
+
homepage: https://github.com/rtomayko/posix-spawn
|
61
76
|
licenses:
|
62
77
|
- MIT
|
78
|
+
- LGPL
|
63
79
|
metadata: {}
|
64
80
|
post_install_message:
|
65
81
|
rdoc_options: []
|