sys-proctable 1.1.1-universal-darwin → 1.1.2-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 +4 -0
- data/lib/darwin/sys/proctable.rb +30 -4
- data/lib/sys/proctable/version.rb +1 -1
- data/sys-proctable.gemspec +1 -1
- data/test/test_sys_proctable_all.rb +1 -1
- data/test/test_sys_proctable_darwin.rb +13 -0
- metadata +18 -18
- 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: 652e5437c3bb1f7b387ddb2eddd4395a82826f97
|
4
|
+
data.tar.gz: 0b464c401191ad8cd20e2a04d6367fe0efa2130d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c7eb21e84df140ee2ee80a2004c5bfb474f046cfb578f266142e23ea0efb47afb17ec0e0faaf6795ca67b6b1bc4371f0fa8ed5e6f17feef50e32c53d6e4d57c
|
7
|
+
data.tar.gz: 8698da48d99fb21fe9d74ce3c1b083a83ac9b33419843a9b4513fa02503ffdb0d5f87bee9a9d946fc85694b2d67d63a6c1a8a4ad1aba5b441f4ce1d6307b6574
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES
CHANGED
data/lib/darwin/sys/proctable.rb
CHANGED
@@ -19,6 +19,7 @@ module Sys
|
|
19
19
|
|
20
20
|
CTL_KERN = 1
|
21
21
|
KERN_PROCARGS = 38
|
22
|
+
KERN_PROCARGS2 = 49
|
22
23
|
MAXCOMLEN = 16
|
23
24
|
MAXPATHLEN = 256
|
24
25
|
|
@@ -273,6 +274,18 @@ module Sys
|
|
273
274
|
# Since we may not have access to the process information due
|
274
275
|
# to improper privileges, just bail if we see a failure here.
|
275
276
|
|
277
|
+
# First use KERN_PROCARGS2 to discover the argc value of the running process.
|
278
|
+
mib.write_array_of_int([CTL_KERN, KERN_PROCARGS2, pid])
|
279
|
+
return if sysctl(mib, 3, nil, len, nil, 0) < 0
|
280
|
+
|
281
|
+
buf = FFI::MemoryPointer.new(:char, len.read_ulong)
|
282
|
+
return if sysctl(mib, 3, buf, len, nil, 0) < 0
|
283
|
+
|
284
|
+
# The argc value is located in the first byte of buf
|
285
|
+
argc = buf.read_bytes(1).ord
|
286
|
+
buf.free
|
287
|
+
|
288
|
+
# Now use KERN_PROCARGS to fetch the rest of the process information
|
276
289
|
mib.write_array_of_int([CTL_KERN, KERN_PROCARGS, pid])
|
277
290
|
return if sysctl(mib, 3, nil, len, nil, 0) < 0
|
278
291
|
|
@@ -284,17 +297,30 @@ module Sys
|
|
284
297
|
|
285
298
|
# Parse the rest of the information out of a big, ugly string
|
286
299
|
array = buf.read_bytes(len.read_ulong).split(0.chr)
|
287
|
-
array.shift # Delete first exe
|
288
300
|
array.delete('') # Delete empty strings
|
301
|
+
|
302
|
+
# The format that sysctl outputs is as follows:
|
303
|
+
#
|
304
|
+
# [full executable path]
|
305
|
+
# [executable name]
|
306
|
+
# [arguments]
|
307
|
+
# [environment variables]
|
308
|
+
# ...
|
309
|
+
# \FF\BF
|
310
|
+
# [full executable path]
|
311
|
+
#
|
312
|
+
# Strip the first executable path and the last two entries from the array.
|
313
|
+
# What is left is the name, arguments, and environment variables
|
314
|
+
array = array[1..-3]
|
289
315
|
|
290
316
|
cmdline = ''
|
291
317
|
|
292
|
-
#
|
293
|
-
|
318
|
+
# Extract the full command line and it's arguments from the array
|
319
|
+
argc.times do
|
294
320
|
cmdline << ' ' + array.shift
|
295
321
|
end
|
296
322
|
|
297
|
-
struct[:cmdline] =
|
323
|
+
struct[:cmdline] = cmdline.strip
|
298
324
|
|
299
325
|
# Anything remaining at this point is a collection of key=value
|
300
326
|
# pairs which we convert into a hash.
|
data/sys-proctable.gemspec
CHANGED
@@ -23,11 +23,16 @@ class TC_ProcTable_Darwin < Test::Unit::TestCase
|
|
23
23
|
exec('env', '-i', 'A=B', 'Z=', 'sleep', '60')
|
24
24
|
end
|
25
25
|
|
26
|
+
@@pid2 = fork do
|
27
|
+
exec('php', '-d setting=true', '-d directory=/usr/bin', '-R', '\'sleep(120);\'')
|
28
|
+
end
|
29
|
+
|
26
30
|
sleep 1 # wait to make sure env is replaced by sleep
|
27
31
|
end
|
28
32
|
|
29
33
|
def setup
|
30
34
|
@ptable = Sys::ProcTable.ps(@@pid)
|
35
|
+
@ptable2 = Sys::ProcTable.ps(@@pid2)
|
31
36
|
end
|
32
37
|
|
33
38
|
test "fields basic functionality" do
|
@@ -90,6 +95,12 @@ class TC_ProcTable_Darwin < Test::Unit::TestCase
|
|
90
95
|
assert_equal('sleep 60', @ptable.cmdline)
|
91
96
|
end
|
92
97
|
|
98
|
+
test "cmdline struct member is defined and returns expected value" do
|
99
|
+
assert_respond_to(@ptable2, :cmdline)
|
100
|
+
assert_kind_of(String, @ptable2.cmdline)
|
101
|
+
assert_equal('php -d setting=true -d directory=/usr/bin -R \'sleep(120);\'', @ptable2.cmdline)
|
102
|
+
end
|
103
|
+
|
93
104
|
test "exe struct member is defined and returns expected value" do
|
94
105
|
assert_respond_to(@ptable, :exe)
|
95
106
|
assert_kind_of(String, @ptable.exe)
|
@@ -104,10 +115,12 @@ class TC_ProcTable_Darwin < Test::Unit::TestCase
|
|
104
115
|
|
105
116
|
def teardown
|
106
117
|
@ptable = nil
|
118
|
+
@ptable2 = nil
|
107
119
|
end
|
108
120
|
|
109
121
|
def self.shutdown
|
110
122
|
@@fields = nil
|
111
123
|
Process.kill('TERM', @@pid)
|
124
|
+
Process.kill('TERM', @@pid2)
|
112
125
|
end
|
113
126
|
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.2
|
5
5
|
platform: universal-darwin
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -12,25 +12,25 @@ cert_chain:
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
|
14
14
|
cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
|
15
|
-
|
15
|
+
MB4XDTE2MDkxOTAzNDY0NVoXDTE3MDkxOTAzNDY0NVowPzERMA8GA1UEAwwIZGpi
|
16
16
|
ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM0eOHOQRpLOeqkyeK7O
|
18
|
+
DGHYLkO0Wq7gStVVVyHXahgyCopLN6JVBwGy5aCpKFcy5sFz2DdnISj+hQ7FctDa
|
19
|
+
yz6Lq9TvAF8Jkis8dDFLQKeHilB/AM4ssQAsGQyoQnoE4v5tCOSW4e3YHFDp/dMZ
|
20
|
+
s7Hkoim6PeEdkh4hB5LCa90OrHSPe8nlMFsVhRIGj86xNTRazEiWPZCOKmN9rZgW
|
21
|
+
ziheP/6hC2c7vNRevv5iE/K+NqaL/WOdMquOSZoF2mdBcoMIPDDBNzh/oHinPQ3N
|
22
|
+
1oOvoET0+Tj+O5tXX/L1TAsUrwZXlyrYGaZ5aYyoo/7r9pmvmbfgBqaU6JywT0EE
|
23
|
+
5x0CAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFO+k
|
24
|
+
C/3R+t2aIyIpwU5wPrAfYVL6MB0GA1UdEQQWMBSBEmRqYmVyZzk2QGdtYWlsLmNv
|
25
25
|
bTAdBgNVHRIEFjAUgRJkamJlcmc5NkBnbWFpbC5jb20wDQYJKoZIhvcNAQEFBQAD
|
26
|
-
|
27
|
-
|
28
|
-
/
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
ggEBAIJWpqQOUMoYhpm0wJ4kfiYv9rZVbpZ3L2cFYt4O6+wgbpdWP8DBBgZfCSQW
|
27
|
+
1J9miChMKdxZ8eOoeId79IMXN3IAcnalTFvD0Rp9ltaFZTXBfXMFqxQN3fHsIVwz
|
28
|
+
as/JSbwXo/PE8rULhjU+Utwcmji38cKEDWLAW4vsCBmwvBTwmAmcuHHKjnNvd8aR
|
29
|
+
YMrq9v505w8IjSysIO3KKysxCFuzoIPIYMdYswquvmtuTA+lpB9btWHr8n2FFsDp
|
30
|
+
A943I/wqE6xbYQpHxkndWo5uLDUbZh+XxG+fhZKpeqLIqHaFuU6wdO5odt32kB/B
|
31
|
+
nCjVswaVYlu1U2iLPCqE+MrjmTA=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2016-
|
33
|
+
date: 2016-09-19 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.6
|
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
|