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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 536255fca496dc375430fe9698a5f277fdd8db10
4
- data.tar.gz: f108e5642d8312dae6fc598023c2a2703320278a
3
+ metadata.gz: 652e5437c3bb1f7b387ddb2eddd4395a82826f97
4
+ data.tar.gz: 0b464c401191ad8cd20e2a04d6367fe0efa2130d
5
5
  SHA512:
6
- metadata.gz: 113ed8abaa560fd6abaa75b545eb9d068c8a510c388ea0eda1c97ba80a2571df9ae11653888920e42f93e775920df151bc65ea9f835a94ef0bb3dcc7bad2f925
7
- data.tar.gz: 7d0eb460512b0c1f9cb8173de138069cea86382f0b4173845479c79855e8cbfc8239dbb907b1b8dad00b1511438dfda4f3a40613e782183ec5ee17a47140085b
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
@@ -1,3 +1,7 @@
1
+ == 1.1.2 - 18-Sep-2016
2
+ * Fixed cmdline parsing and handling for OSX. Thanks go to Ben Mathwig for
3
+ the spot and the patch.
4
+
1
5
  == 1.1.1 - 30-Jun-2016
2
6
  * Added thread information for OS X.
3
7
  * Fixed VERSION constant for HP-UX.
@@ -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
- # Anything that doesn't include a '=' sign is a cmdline argument.
293
- while array[0] && !array[0].include?('=')
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] = File.basename(cmdline.strip)
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.
@@ -1,6 +1,6 @@
1
1
  module Sys
2
2
  class ProcTable
3
3
  # The version of the sys-proctable library
4
- VERSION = '1.1.1'.freeze
4
+ VERSION = '1.1.2'.freeze
5
5
  end
6
6
  end
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-proctable'
5
- spec.version = '1.1.1'
5
+ spec.version = '1.1.2'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache 2.0'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -19,7 +19,7 @@ class TC_ProcTable_All < Test::Unit::TestCase
19
19
  end
20
20
 
21
21
  test "version is set to expected value" do
22
- assert_equal('1.1.1', ProcTable::VERSION)
22
+ assert_equal('1.1.2', ProcTable::VERSION)
23
23
  end
24
24
 
25
25
  test "fields basic functionality" do
@@ -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.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
- MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
15
+ MB4XDTE2MDkxOTAzNDY0NVoXDTE3MDkxOTAzNDY0NVowPzERMA8GA1UEAwwIZGpi
16
16
  ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
17
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
18
- Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
19
- S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9yF7imEM8Kz9ojhiDXzBetdV6M
20
- gr0lV/alUr7TNVBDngbXEfTWscyXh1qd7xZ4EcOdsDktCe5G45N/o3662tPQvJsi
21
- FOF0CM/KuBsa/HL1/eoEmF4B3EKIRfTHrQ3hu20Kv3RJ88QM4ec2+0dd97uX693O
22
- zv6981fyEg+aXLkxrkViM/tz2qR2ZE0jPhHTREPYeMEgptRkTmWSKAuLVWrJEfgl
23
- DtkCAwEAAaN3M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x+ndQYaeyCn+GRX2PKS9h66YF/Q1V
31
- tGSHgAmcLlkdGgan182qsE/4kKM=
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-07-01 00:00:00.000000000 Z
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.4
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