process_executer 1.0.2 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05077fa5757c373b7587a35c2f32aaa3deeaa5708845ec5db485fccb4f29bc5c
4
- data.tar.gz: 9b1fda5d3669f6f09100e2b4b47ec8905d8448632cbd1998af0e606d724967cf
3
+ metadata.gz: f568a98075e32879207b26949346e4181eed2d2432c9665e84ddb015d5ded96c
4
+ data.tar.gz: bcc6f74e77155a251d4ad561495f6edb1b6cf95bccc23b7de7322a0897d4a0af
5
5
  SHA512:
6
- metadata.gz: 6f48795cd44788c27a9931a1960e9d5f83d72ab794fd37d5d24b0a3110a1582211f80cdeef4e8cd171183f3ef9ccfec615f60fda46dd480cdaed10856d69a373
7
- data.tar.gz: 54b9a282d8dc8d0ebca8e5e2b1368a0040ec140c5a793d438fe4891363d74574b31541d9d22aea566f09f8b3284cb7d12c49f071f9dca3cd29bbcd8df9babfbe
6
+ metadata.gz: 0fc886fade1e486d6acb6c32864a469a6d77700c596dd15a47c4e59e440bfda06b3a1ca506fc4a9be8f7d3bea831525329e735d9cb30d5c01d48395571f9164c
7
+ data.tar.gz: cab6c4b4d5d1761ac46df3aff8c02c44fed93d071bc6c74fdba802c04175321520c92556c8a43fe79bf3f56d9fb80b82e1b7b60ff50c1bdea8fdcf94bb2e22fd
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to the process_executer gem will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## v1.1.0 (2024-02-02)
9
+
10
+ [Full Changelog](https://github.com/main-branch/process_executer/compare/v1.0.2..v1.1.0)
11
+
12
+ Changes since v1.0.2:
13
+
14
+ * a473281 ProcessExecuter.spawn should indicate if the subprocess timed out or not (#43)
15
+
8
16
  ## v1.0.2 (2024-02-01)
9
17
 
10
18
  [Full Changelog](https://github.com/main-branch/process_executer/compare/v1.0.1..v1.0.2)
data/README.md CHANGED
@@ -77,7 +77,15 @@ important behaviorial differences:
77
77
  2. A timeout can be specified using the `:timeout` option
78
78
 
79
79
  If the command does not terminate before the timeout, the process is killed by
80
- sending it the SIGKILL signal.
80
+ sending it the SIGKILL signal. The returned status object's `timeout?` attribute will
81
+ return `true`. For example:
82
+
83
+ ```ruby
84
+ status = ProcessExecuter.spawn('sleep 10', timeout: 0.01)
85
+ status.signaled? #=> true
86
+ status.termsig #=> 9
87
+ status.timeout? #=> true
88
+ ```
81
89
 
82
90
  ## Installation
83
91
 
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'delegate'
4
+
5
+ module ProcessExecuter
6
+ # A simple delegator for Process::Status that adds a `timeout?` attribute
7
+ #
8
+ # @api public
9
+ #
10
+ class Status < SimpleDelegator
11
+ extend Forwardable
12
+
13
+ # Create a new Status object from a Process::Status and timeout flag
14
+ #
15
+ # @param status [Process::Status] the status to delegate to
16
+ # @param timeout [Boolean] true if the process timed out
17
+ #
18
+ # @example
19
+ # status = Process.wait2(pid).last
20
+ # timeout = false
21
+ # ProcessExecuter::Status.new(status, timeout)
22
+ #
23
+ # @api public
24
+ #
25
+ def initialize(status, timeout)
26
+ super(status)
27
+ @timeout = timeout
28
+ end
29
+
30
+ # @!attribute [r] timeout?
31
+ #
32
+ # True if the process timed out and was sent the SIGKILL signal
33
+ #
34
+ # @example
35
+ # status = ProcessExecuter.spawn('sleep 10', timeout: 0.01)
36
+ # status.timeout? # => true
37
+ #
38
+ # @return [Boolean]
39
+ #
40
+ # @api public
41
+ #
42
+ def timeout? = @timeout
43
+ end
44
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module ProcessExecuter
4
4
  # The current Gem version
5
- VERSION = '1.0.2'
5
+ VERSION = '1.1.0'
6
6
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'process_executer/monitored_pipe'
4
4
  require 'process_executer/options'
5
+ require 'process_executer/status'
5
6
 
6
7
  require 'timeout'
7
8
 
@@ -59,16 +60,16 @@ module ProcessExecuter
59
60
  # @param pid [Integer] the process id
60
61
  # @param options [ProcessExecuter::Options] the options used
61
62
  #
62
- # @return [Process::Status] the status of the process
63
+ # @return [ProcessExecuter::Status] the status of the process
63
64
  #
64
65
  # @api private
65
66
  #
66
67
  private_class_method def self.wait_for_process(pid, options)
67
68
  Timeout.timeout(options.timeout) do
68
- Process.wait2(pid).last
69
+ ProcessExecuter::Status.new(Process.wait2(pid).last, false)
69
70
  end
70
71
  rescue Timeout::Error
71
72
  Process.kill('KILL', pid)
72
- Process.wait2(pid).last
73
+ ProcessExecuter::Status.new(Process.wait2(pid).last, true)
73
74
  end
74
75
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_executer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Couball
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-02 00:00:00.000000000 Z
11
+ date: 2024-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler-audit
@@ -190,6 +190,7 @@ files:
190
190
  - lib/process_executer.rb
191
191
  - lib/process_executer/monitored_pipe.rb
192
192
  - lib/process_executer/options.rb
193
+ - lib/process_executer/status.rb
193
194
  - lib/process_executer/version.rb
194
195
  - process_executer.gemspec
195
196
  homepage: https://github.com/main-branch/process_executer
@@ -199,8 +200,8 @@ metadata:
199
200
  allowed_push_host: https://rubygems.org
200
201
  homepage_uri: https://github.com/main-branch/process_executer
201
202
  source_code_uri: https://github.com/main-branch/process_executer
202
- changelog_uri: https://rubydoc.info/gems/process_executer/1.0.2/file/CHANGELOG.md
203
- documentation_uri: https://rubydoc.info/gems/process_executer/1.0.2
203
+ changelog_uri: https://rubydoc.info/gems/process_executer/1.1.0/file/CHANGELOG.md
204
+ documentation_uri: https://rubydoc.info/gems/process_executer/1.1.0
204
205
  rubygems_mfa_required: 'true'
205
206
  post_install_message:
206
207
  rdoc_options: []