sys-proctable 1.1.3-universal-darwin → 1.1.4-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES +5 -0
- data/Rakefile +2 -2
- data/lib/darwin/sys/proctable.rb +6 -1
- data/lib/sys/proctable/version.rb +1 -1
- data/lib/sys/top.rb +4 -3
- data/sys-proctable.gemspec +1 -1
- data/test/test_sys_proctable_all.rb +1 -1
- data/test/test_sys_proctable_darwin.rb +3 -3
- data/test/test_sys_top.rb +1 -15
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab19802eaa8c764de655146264c9d60804c993ab
|
4
|
+
data.tar.gz: 1acdf47db24542fe7be5da187462563d9fac9da5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9b7db449e6936a73125a72d7cf530c2047abe4d4b1d7aec4853f343afd70ef06b05bb354278a9c8b0ac1808c2b5bc35825ca495a79a95ca26bc78e909900693
|
7
|
+
data.tar.gz: 9be1631fe872ebc1d918f8e2fce9028fd246f6cd9d446b5fcec3c6cae0ed250b3c5a60aa5ecd9aff923c12b5a8f3f9913670d1a748a88d6ea2d1b37da48045f5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 1.1.4 - 30-Mar-2017
|
2
|
+
* Fixed a potential issue where OSX could return a struct with invalid data.
|
3
|
+
* Set the default field to :pid for OSX when using Sys::Top.
|
4
|
+
* Fixed a duplicate test warning for OSX.
|
5
|
+
|
1
6
|
== 1.1.3 - 28-Sep-2016
|
2
7
|
* Fixed an issue on OSX where the value returned for argc is invalid.
|
3
8
|
|
data/Rakefile
CHANGED
data/lib/darwin/sys/proctable.rb
CHANGED
@@ -175,7 +175,9 @@ module Sys
|
|
175
175
|
next unless pid == lpid if pid
|
176
176
|
info = ProcTaskAllInfo.new
|
177
177
|
|
178
|
-
|
178
|
+
nb = proc_pidinfo(lpid, PROC_PIDTASKALLINFO, 0, info, info.size)
|
179
|
+
|
180
|
+
if nb <= 0
|
179
181
|
if [Errno::EPERM::Errno, Errno::ESRCH::Errno].include?(FFI.errno)
|
180
182
|
next # Either we don't have permission, or the pid no longer exists
|
181
183
|
else
|
@@ -183,6 +185,9 @@ module Sys
|
|
183
185
|
end
|
184
186
|
end
|
185
187
|
|
188
|
+
# Avoid potentially invalid data
|
189
|
+
next if nb != info.size
|
190
|
+
|
186
191
|
struct = ProcTableStruct.new
|
187
192
|
|
188
193
|
# Pass by reference
|
data/lib/sys/top.rb
CHANGED
@@ -7,21 +7,22 @@ module Sys
|
|
7
7
|
class Top
|
8
8
|
|
9
9
|
# The version of the sys-top library
|
10
|
-
VERSION = '1.0.
|
10
|
+
VERSION = '1.0.5'.freeze
|
11
11
|
|
12
12
|
# Returns an array of Struct::ProcTableStruct elements containing up
|
13
13
|
# to +num+ elements, sorted by +field+. The default number of elements
|
14
14
|
# is 10, while the default field is 'pctcpu'.
|
15
15
|
#
|
16
|
-
# Exception: the default sort field is 'pid' on AIX and Windows.
|
16
|
+
# Exception: the default sort field is 'pid' on AIX, Darwin and Windows.
|
17
17
|
#
|
18
18
|
def self.top(num=10, field='pctcpu')
|
19
19
|
field = field.to_s if field.is_a?(Symbol)
|
20
20
|
|
21
21
|
aix = RbConfig::CONFIG['host_os'] =~ /aix/i
|
22
|
+
darwin = RbConfig::CONFIG['host_os'] =~ /darwin/i
|
22
23
|
|
23
24
|
# Sort by pid on Windows and AIX by default
|
24
|
-
if (File::ALT_SEPARATOR || aix) && field == 'pctcpu'
|
25
|
+
if (File::ALT_SEPARATOR || aix || darwin) && field == 'pctcpu'
|
25
26
|
field = 'pid'
|
26
27
|
end
|
27
28
|
|
data/sys-proctable.gemspec
CHANGED
@@ -24,7 +24,7 @@ class TC_ProcTable_Darwin < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
@@pid2 = fork do
|
27
|
-
exec('
|
27
|
+
exec('ruby', '-Ilib', '-e', 'sleep \'120\'.to_i', '--', 'foo bar')
|
28
28
|
end
|
29
29
|
|
30
30
|
sleep 1 # wait to make sure env is replaced by sleep
|
@@ -95,10 +95,10 @@ class TC_ProcTable_Darwin < Test::Unit::TestCase
|
|
95
95
|
assert_equal('sleep 60', @ptable.cmdline)
|
96
96
|
end
|
97
97
|
|
98
|
-
test "cmdline struct member is defined and returns expected
|
98
|
+
test "cmdline struct member is defined and returns expected string with arguments" do
|
99
99
|
assert_respond_to(@ptable2, :cmdline)
|
100
100
|
assert_kind_of(String, @ptable2.cmdline)
|
101
|
-
assert_equal('
|
101
|
+
assert_equal('ruby -Ilib -e sleep \'120\'.to_i -- foo bar', @ptable2.cmdline)
|
102
102
|
end
|
103
103
|
|
104
104
|
test "exe struct member is defined and returns expected value" do
|
data/test/test_sys_top.rb
CHANGED
@@ -11,12 +11,8 @@ require 'sys/top'
|
|
11
11
|
class TC_Top < Test::Unit::TestCase
|
12
12
|
include Sys
|
13
13
|
|
14
|
-
def setup
|
15
|
-
@osx = RbConfig::CONFIG['host_os'] =~ /darwin/i
|
16
|
-
end
|
17
|
-
|
18
14
|
test "top version" do
|
19
|
-
assert_equal('1.0.
|
15
|
+
assert_equal('1.0.5', Top::VERSION)
|
20
16
|
end
|
21
17
|
|
22
18
|
test "top basic functionality" do
|
@@ -24,42 +20,32 @@ class TC_Top < Test::Unit::TestCase
|
|
24
20
|
end
|
25
21
|
|
26
22
|
test "top works with no arguments" do
|
27
|
-
omit_if(@osx)
|
28
23
|
assert_nothing_raised{ Top.top }
|
29
24
|
end
|
30
25
|
|
31
26
|
test "top accepts optional arguments" do
|
32
|
-
omit_if(@osx)
|
33
27
|
assert_nothing_raised{ Top.top(5) }
|
34
28
|
assert_nothing_raised{ Top.top(5, 'cmdline') }
|
35
29
|
end
|
36
30
|
|
37
31
|
test "top with no arguments returns expected results" do
|
38
|
-
omit_if(@osx)
|
39
32
|
assert_equal(10, Top.top.length)
|
40
33
|
assert_kind_of(Struct::ProcTableStruct, Top.top.first)
|
41
34
|
end
|
42
35
|
|
43
36
|
test "top with size argument returns expected result" do
|
44
|
-
omit_if(@osx)
|
45
37
|
assert_equal(5, Top.top(5).length)
|
46
38
|
end
|
47
39
|
|
48
40
|
test "top with size and sort_by argument returns expected result" do
|
49
|
-
omit_if(@osx)
|
50
41
|
assert_equal(5, Top.top(5, :cmdline).length)
|
51
42
|
end
|
52
43
|
|
53
44
|
test "top returns an array" do
|
54
|
-
omit_if(@osx)
|
55
45
|
assert_kind_of(Array, Top.top)
|
56
46
|
end
|
57
47
|
|
58
48
|
test "top accepts a maximum of two arguments" do
|
59
49
|
assert_raises(ArgumentError){ Top.top(1, 'foo', 2) }
|
60
50
|
end
|
61
|
-
|
62
|
-
def teardown
|
63
|
-
@osx = nil
|
64
|
-
end
|
65
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-proctable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: universal-darwin
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
A943I/wqE6xbYQpHxkndWo5uLDUbZh+XxG+fhZKpeqLIqHaFuU6wdO5odt32kB/B
|
31
31
|
nCjVswaVYlu1U2iLPCqE+MrjmTA=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
33
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: test-unit
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.6.
|
126
|
+
rubygems_version: 2.6.11
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: An interface for providing process table information
|
metadata.gz.sig
CHANGED
Binary file
|