frontkick 0.4.4 → 0.4.5
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/CHANGELOG.md +6 -0
- data/README.md +2 -2
- data/example/run.rb +4 -0
- data/experiment/capture3_no_deadlock.rb +8 -0
- data/experiment/cat_63k.rb +5 -0
- data/experiment/cat_64k.rb +5 -0
- data/experiment/popen3_deadlock.rb +15 -0
- data/experiment/popen3_no_deadlock.rb +16 -0
- data/lib/frontkick/command.rb +4 -2
- data/lib/frontkick/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90e8f994ea85285a3a1f0130061293b7fc557366
|
4
|
+
data.tar.gz: b9e07e7c2dcd214347e6aa1fb45b523e515e323a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 210662fde91518f8c9a40dfbbe3516df357d8bbfcd00d16bd9e496cd68f0dca6fabe273ca68dd7914324cd3329fb482cf769a937ec3e7259a64cbc1dbf3ebac7
|
7
|
+
data.tar.gz: b1f7dc35e1542f1aa350001859b42ec0920ff63c20084478ed429ea339cde1d85d6ec1caa3046b2c2e4be9b2968ed3e6b8a607b841eb6c99365217b3dd35fdf8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,12 +19,12 @@ With frontkick, you can easily get the exit code, STDOUT, and STDERR.
|
|
19
19
|
|
20
20
|
result = Frontkick.exec("echo *")
|
21
21
|
puts result.successful? #=> true if exit_code is 0
|
22
|
-
puts result.success? #=> alias to successful
|
22
|
+
puts result.success? #=> alias to successful?, for compatibility with Process::Status
|
23
23
|
puts result.stdout #=> stdout output of the command
|
24
24
|
puts result.stderr #=> stderr output of the command
|
25
25
|
puts result.exit_code #=> exit_code of the command
|
26
26
|
puts result.status #=> alias to exit_code
|
27
|
-
puts result.exitstatus #=> alias to exit_code
|
27
|
+
puts result.exitstatus #=> alias to exit_code, for compatibility with Process::Status
|
28
28
|
puts result.duration #=> the time used to execute the command
|
29
29
|
|
30
30
|
### Escape Command
|
data/example/run.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
# popen3 blocks if pipe buffer size overs 64k (depends on system, this is on my Mac)
|
4
|
+
# the child process waits its buffer to be read, but the parent process waits the child
|
5
|
+
# process finishes and returns EOF, hence deadlocks
|
6
|
+
|
7
|
+
cmd_array = ['./cat_64k.rb']
|
8
|
+
stdin, out, err, wait_thr = Open3.popen3(*cmd_array)
|
9
|
+
stdin.close
|
10
|
+
pid = wait_thr.pid
|
11
|
+
stdout = out.read
|
12
|
+
stderr = err.read
|
13
|
+
exit_code = wait_thr.value.exitstatus
|
14
|
+
|
15
|
+
puts 'no deadlock'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
# popen3 without deadlock version
|
4
|
+
# almost same with what capture3 does
|
5
|
+
|
6
|
+
cmd_array = ['./cat_64k.rb']
|
7
|
+
stdin, out, err, wait_thr = Open3.popen3(*cmd_array)
|
8
|
+
out_reader = Thread.new { out.read }
|
9
|
+
err_reader = Thread.new { err.read }
|
10
|
+
stdin.close
|
11
|
+
pid = wait_thr.pid
|
12
|
+
stdout = out_reader.value
|
13
|
+
stderr = err_reader.value
|
14
|
+
exit_code = wait_thr.value.exitstatus
|
15
|
+
|
16
|
+
puts 'no deadlock'
|
data/lib/frontkick/command.rb
CHANGED
@@ -22,10 +22,12 @@ module Frontkick
|
|
22
22
|
timeout(opts[:timeout], Frontkick::TimeoutLocal) do # nil is for no timeout
|
23
23
|
duration = Benchmark.realtime do
|
24
24
|
stdin, out, err, wait_thr = Open3.popen3(*cmd_array)
|
25
|
+
out_reader = Thread.new { out.read }
|
26
|
+
err_reader = Thread.new { err.read }
|
25
27
|
stdin.close
|
26
28
|
pid = wait_thr.pid
|
27
|
-
stdout =
|
28
|
-
stderr =
|
29
|
+
stdout = out_reader.value
|
30
|
+
stderr = err_reader.value
|
29
31
|
exit_code = wait_thr.value.exitstatus
|
30
32
|
process_wait(pid)
|
31
33
|
end
|
data/lib/frontkick/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frontkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -68,6 +68,12 @@ files:
|
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
70
|
- example/dry_run.rb
|
71
|
+
- example/run.rb
|
72
|
+
- experiment/capture3_no_deadlock.rb
|
73
|
+
- experiment/cat_63k.rb
|
74
|
+
- experiment/cat_64k.rb
|
75
|
+
- experiment/popen3_deadlock.rb
|
76
|
+
- experiment/popen3_no_deadlock.rb
|
71
77
|
- frontkick.gemspec
|
72
78
|
- lib/frontkick.rb
|
73
79
|
- lib/frontkick/command.rb
|