multi_timeout 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- t��O_?X�#�]G
2
- Z|�v���qsd��p#W�E#� -Ryҽ��RdV�J���Ȯ�䞜,��2�hw΢|��o���H)l��jW
1
+ J�#�*�ľ�YAA����i0��*�PJc
2
+ *��,�n@~[�py���#��v�@=Q߽�d_���^�v4Y��I���U���*]}���V�~�?J�tIĔ���6Yy��?���gW)g�V@/���G]��/�����uM9 cja4cCT��At <T^��^#yr
3
+ O��+ ��P����vC�����j�./�2JB.�?D$��3y�bQ�L:�Ĵ���[���f3������i��̍�tN
data/lib/multi_timeout.rb CHANGED
@@ -5,13 +5,14 @@ require "optparse"
5
5
  module MultiTimeout
6
6
  module CLI
7
7
  TICK = 1
8
+ VALID_SIGNAL = /^(-(\d+|[A-Z\d]+))$/
8
9
 
9
10
  class << self
10
11
  def run(argv)
11
12
  options = parse_options(argv)
12
13
  command = options[:command]
13
14
 
14
- pid = Process.spawn(command)
15
+ pid = fork { exec command }
15
16
  Thread.new do
16
17
  now = 0
17
18
  loop do
@@ -21,6 +22,7 @@ module MultiTimeout
21
22
  if now >= t
22
23
  options[:timeouts].delete([signal, t])
23
24
  puts "Killing '#{command}' with signal #{signal} after #{now} seconds"
25
+ STDOUT.flush # wait instantly terminates and sometimes hides puts
24
26
  Process.kill(signal, pid)
25
27
  end
26
28
  end
@@ -78,12 +80,13 @@ module MultiTimeout
78
80
  timeouts = []
79
81
  signal = nil
80
82
  argv = argv.map do |item|
81
- if !signal && item =~ /^(-\d+)$/
83
+ if !signal && item =~ VALID_SIGNAL
82
84
  signal = $1
83
85
  next
84
- elsif signal && item =~ /^(\d+[smh]?)$/
85
- time = $1
86
- timeouts << [signal.sub("-", "").to_i, time.to_i * multi(time)]
86
+ elsif signal
87
+ signal = signal.sub("-", "")
88
+ signal = signal.to_i if signal =~ /^\d+$/
89
+ timeouts << [signal, item.to_i * multi(item)]
87
90
  signal = nil
88
91
  next
89
92
  else
@@ -96,10 +99,10 @@ module MultiTimeout
96
99
 
97
100
  def multi(t)
98
101
  case t
99
- when /s/ then 1
100
- when /m/ then 60
101
- when /h/ then 60 * 60
102
- when /^\d+$/ then 1
102
+ when /^\d+s$/ then 1
103
+ when /^\d+m$/ then 60
104
+ when /^\d+h$/ then 60 * 60
105
+ when /^\d+$/ then 1
103
106
  else
104
107
  raise "Unknown format for time #{t}"
105
108
  end
@@ -1,3 +1,3 @@
1
1
  module MultiTimeout
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,19 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: multi_timeout
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 2
10
+ version: 1.0.2
5
11
  platform: ruby
6
- authors:
12
+ authors:
7
13
  - Michael Grosser
8
14
  autorequire:
9
15
  bindir: bin
10
- cert_chain:
16
+ cert_chain:
11
17
  - |
12
18
  -----BEGIN CERTIFICATE-----
13
19
  MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MRAwDgYDVQQDDAdtaWNo
@@ -30,41 +36,55 @@ cert_chain:
30
36
  F5etKHZg0j3eHO31/i2HnswY04lqGImUu6aM5EnijFTB7PPW2KwKKM4+kKDYFdlw
31
37
  /0WV1Ng2/Y6qsHwmqGg2VlYj2h4=
32
38
  -----END CERTIFICATE-----
33
- date: 2014-03-12 00:00:00.000000000 Z
39
+
40
+ date: 2014-03-12 00:00:00 Z
34
41
  dependencies: []
42
+
35
43
  description:
36
44
  email: michael@grosser.it
37
- executables:
45
+ executables:
38
46
  - multi-timeout
39
47
  extensions: []
48
+
40
49
  extra_rdoc_files: []
41
- files:
50
+
51
+ files:
42
52
  - MIT-LICENSE
43
53
  - bin/multi-timeout
44
54
  - lib/multi_timeout.rb
45
55
  - lib/multi_timeout/version.rb
46
56
  homepage: https://github.com/grosser/multi_timeout
47
- licenses:
57
+ licenses:
48
58
  - MIT
49
- metadata: {}
50
59
  post_install_message:
51
60
  rdoc_options: []
52
- require_paths:
61
+
62
+ require_paths:
53
63
  - lib
54
- required_ruby_version: !ruby/object:Gem::Requirement
55
- requirements:
56
- - - '>='
57
- - !ruby/object:Gem::Version
58
- version: '0'
59
- required_rubygems_version: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - '>='
62
- - !ruby/object:Gem::Version
63
- version: '0'
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
64
82
  requirements: []
83
+
65
84
  rubyforge_project:
66
- rubygems_version: 2.0.14
85
+ rubygems_version: 1.8.20
67
86
  signing_key:
68
- specification_version: 4
87
+ specification_version: 3
69
88
  summary: Use multiple timeouts to soft and then hard kill a command
70
89
  test_files: []
90
+
metadata.gz.sig CHANGED
Binary file
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: d5adcedd7acbe7bdc5e9bf80656b6155effc28ff
4
- data.tar.gz: 6868dc91d8edd301604ae7e30364173348f9a178
5
- SHA512:
6
- metadata.gz: 0522ff701fd8f7733af8121cfb99aac8904b8fcdef470414f5dea742b30b4bbf2eec5b66c47609e37268c27cbb4c0f9faf7b2527f3cbe39b29268875e5ee47f1
7
- data.tar.gz: 9f03c222e690f8fdf21866d174bea800a4a87bcef3ad3d3faf1c649cb2d3b3f732c2b9638dd856ff7fca0cbda158ca4b8e12d33fd9a8280863fa9cd88ac93241
checksums.yaml.gz.sig DELETED
Binary file