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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa4731922579e811c8e634317d8115e6dbb7231b
4
- data.tar.gz: 6b9f76e34a8ff11fb612042290f3147de357e4b6
3
+ metadata.gz: 90e8f994ea85285a3a1f0130061293b7fc557366
4
+ data.tar.gz: b9e07e7c2dcd214347e6aa1fb45b523e515e323a
5
5
  SHA512:
6
- metadata.gz: 131147b154b59ec5993648efce84edcbf8ef87674eafd64bd5e558e8d183abde745daa651a457ec669b38af7b413d3464fc83161cd2359972377348cd8288825
7
- data.tar.gz: 798c5aff4f2aa9feaa249ff818763d3ee1de6ed71f5ddfbfe631f562bfbea8ca05e07fccd808fbde8d910adf1e0f811302f0ff764e8ed1543e7eae2f76d27608
6
+ metadata.gz: 210662fde91518f8c9a40dfbbe3516df357d8bbfcd00d16bd9e496cd68f0dca6fabe273ca68dd7914324cd3329fb482cf769a937ec3e7259a64cbc1dbf3ebac7
7
+ data.tar.gz: b1f7dc35e1542f1aa350001859b42ec0920ff63c20084478ed429ea339cde1d85d6ec1caa3046b2c2e4be9b2968ed3e6b8a607b841eb6c99365217b3dd35fdf8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.4.5 (2016/01/05)
2
+
3
+ Fixes:
4
+
5
+ - Avoid pipe deadlock
6
+
1
7
  # 0.4.4 (2015/11/25)
2
8
 
3
9
  Fixes:
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,4 @@
1
+ require 'frontkick'
2
+
3
+ result = Frontkick.exec(["#{__dir__}/../experiment/cat_64k.rb"])
4
+ puts result.stdout
@@ -0,0 +1,8 @@
1
+ require 'open3'
2
+
3
+ # capture3 handles the deadlock problem of popen3, no deadlock occurs
4
+
5
+ cmd_array = ['./cat_64k.rb']
6
+ stdout, stderr, status = Open3.capture3(*cmd_array, :stdin_data => '')
7
+
8
+ puts 'no daedlock'
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ str = 'a' * (63 * 1024)
4
+ STDERR.puts str
5
+ STDOUT.puts str
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ str = 'a' * (64 * 1024)
4
+ STDERR.puts str
5
+ STDOUT.puts str
@@ -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'
@@ -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 = out.read
28
- stderr = err.read
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
@@ -1,3 +1,3 @@
1
1
  module Frontkick
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
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
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: 2015-11-25 00:00:00.000000000 Z
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