subcontractor 0.4.1 → 0.5.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.
- data/lib/subcontractor/cli.rb +17 -1
- data/lib/subcontractor/version.rb +1 -1
- metadata +5 -5
data/lib/subcontractor/cli.rb
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'pty'
|
3
3
|
|
4
|
+
module SafePty
|
5
|
+
def self.spawn command, &block
|
6
|
+
|
7
|
+
PTY.spawn(command) do |r,w,p|
|
8
|
+
begin
|
9
|
+
yield r,w,p
|
10
|
+
rescue Errno::EIO
|
11
|
+
ensure
|
12
|
+
Process.wait p
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
$?.exitstatus
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
4
20
|
module Subcontractor
|
5
21
|
class CLI
|
6
22
|
|
@@ -9,7 +25,7 @@ module Subcontractor
|
|
9
25
|
command = build_command(ARGV.dup, options)
|
10
26
|
Dir.chdir(options[:chdir]) if options[:chdir]
|
11
27
|
signal = options[:signal] || "TERM"
|
12
|
-
|
28
|
+
SafePty.spawn(command) do |stdin, stdout, pid|
|
13
29
|
trap("TERM") do
|
14
30
|
send_kill(signal, find_pids_to_kill(pid))
|
15
31
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subcontractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tony Pitluga
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-01-24 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: rvm aware process launcher for foreman
|