sys-proctable 0.9.6-universal-darwin → 0.9.8-universal-darwin

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
  SHA1:
3
- metadata.gz: f940ae8b3bc7264a8c92d5363b9a4956b94143fa
4
- data.tar.gz: 7baaa9ab3d5dbbbc7f887beeba7d9f15fa4287b5
3
+ metadata.gz: 5c0f277bcb390cbb37ee944f42c7f132f9ba1d6b
4
+ data.tar.gz: 03f34300349b231abdd4d7939e8beee52053dea2
5
5
  SHA512:
6
- metadata.gz: fccda023f19c3f97026ec37388b8980178d268659477bb8c86079eb8953c02400ee98037f63cab72396b75abcba9a9cb2bf2d4fe3c8007881c5b9b998020479e
7
- data.tar.gz: 19dcdfb85e4529b1a324224fb25a4036cf68dead3ee8126ba25fcb9a548c43756b753da17c9c69c5bb58e81dc4fed478b71368aa7b79d28b0dc22f1000892bee
6
+ metadata.gz: 7dcb080bac19fab492d84fe70adf08e05531a4321543ed931b12bf5485c98ce8c8c3155f55dea6552744fd2e8d7d721e063eaedf6ded5a52a75f2e87216b87bb
7
+ data.tar.gz: 46fcb3170cf7841ab198d57ec79a3215f4f8dba177edfcf814de705c6aa5e38b2b9c54a0ff5bd0a9ffa8b7b339f9adf2734cee4d9bf67669c8856b650beee6a7
data/CHANGES CHANGED
@@ -1,3 +1,15 @@
1
+ == 0.9.8 - 18-Apr-2015
2
+ * Fixed a bug in the gemspec. Last version got yanked.
3
+
4
+ == 0.9.7 - 18-Apr-2015
5
+ * Fixed a bug in the OSX code that could cause the ps method to fail. Thanks
6
+ go to Koshevoy Anton for the spot.
7
+ * Some internal refactoring of version handling. Now all platforms use a
8
+ single version file.
9
+ * Replaced vm_size_t and lwpid_t with universal data types on FreeBSD because
10
+ FFI on FreeBSD 10 no longer understands them. Thanks go to Mike Owens for
11
+ the spot.
12
+
1
13
  == 0.9.6 - 24-Feb-2015
2
14
  * Added NLWP field on Linux. Thanks go to Rich Chatterton for the patch.
3
15
 
data/MANIFEST CHANGED
@@ -16,6 +16,7 @@
16
16
  * ext/hpux/extconf.rb
17
17
  * ext/hpux/sys/proctable.c
18
18
  * lib/sys/top.rb
19
+ * lib/sys/proctable/version.rb
19
20
  * lib/aix/sys/proctable.rb
20
21
  * lib/freebsd/sys/proctable.rb
21
22
  * lib/linux/sys/proctable.rb
data/README CHANGED
@@ -43,7 +43,7 @@
43
43
  # Return the results as an array of ProcTableStructs
44
44
  a = ProcTable.ps
45
45
  a.each do |p|
46
- puts a.pid
46
+ puts p.pid
47
47
  # ...
48
48
  end
49
49
 
data/Rakefile CHANGED
@@ -191,7 +191,7 @@ namespace :gem do
191
191
  desc 'Install the sys-proctable library as a gem'
192
192
  task :install => [:create] do
193
193
  gem_name = Dir['*.gem'].first
194
- sh "gem install #{gem_name}"
194
+ sh "gem install -l #{gem_name}"
195
195
  end
196
196
  end
197
197
 
@@ -20,8 +20,6 @@
20
20
 
21
21
  #define pid_of(pproc) pproc->kp_proc.p_pid
22
22
 
23
- #define SYS_PROCTABLE_VERSION "0.9.6"
24
-
25
23
  #define PROC_MIB_LEN 4
26
24
  #define ARGS_MIB_LEN 3
27
25
 
@@ -32,27 +30,21 @@
32
30
  VALUE cProcTableError, sProcStruct;
33
31
 
34
32
  int argv_of_pid(int pid, VALUE* v_cmdline, VALUE* v_exe, VALUE* v_environ) {
35
- int mib[3], argmax, nargs, c = 0;
36
- size_t size;
37
- char *procargs, *sp, *np, *cp;
33
+ int mib[3], argmax, nargs, c = 0;
34
+ size_t size;
35
+ char *procargs, *sp, *np, *cp;
38
36
  int show_args = 1;
39
37
 
40
- /* fprintf(stderr, "Getting argv of PID %d\n", pid); */
41
-
42
38
  mib[0] = CTL_KERN;
43
39
  mib[1] = KERN_ARGMAX;
44
40
 
45
41
  size = sizeof(argmax);
46
- if (sysctl(mib, 2, &argmax, &size, NULL, 0) == -1) {
47
- goto ERROR_A;
48
- }
49
42
 
50
- /* Allocate space for the arguments. */
51
- procargs = (char *)malloc(argmax);
52
- if (procargs == NULL) {
43
+ if (sysctl(mib, 2, &argmax, &size, NULL, 0) == -1)
53
44
  goto ERROR_A;
54
- }
55
45
 
46
+ // Allocate space for the arguments.
47
+ procargs = (char *)ruby_xmalloc(argmax);
56
48
 
57
49
  /*
58
50
  * Make a sysctl() call to get the raw argument space of the process.
@@ -99,40 +91,36 @@ int argv_of_pid(int pid, VALUE* v_cmdline, VALUE* v_exe, VALUE* v_environ) {
99
91
  mib[1] = KERN_PROCARGS2;
100
92
  mib[2] = pid;
101
93
 
102
-
103
94
  size = (size_t)argmax;
104
- if (sysctl(mib, 3, procargs, &size, NULL, 0) == -1) {
95
+
96
+ if (sysctl(mib, 3, procargs, &size, NULL, 0) == -1)
105
97
  goto ERROR_B;
106
- }
107
98
 
108
99
  memcpy(&nargs, procargs, sizeof(nargs));
109
100
  cp = procargs + sizeof(nargs);
110
101
 
111
- /* Copy exec_path to ruby String. */
102
+ // Copy exec_path to ruby String.
112
103
  *v_exe = rb_str_new2(cp);
113
104
 
114
- /* Skip the saved exec_path. */
105
+ // Skip the saved exec_path.
115
106
  for (; cp < &procargs[size]; cp++) {
116
- if (*cp == '\0') {
117
- /* End of exec_path reached. */
118
- break;
119
- }
107
+ if (*cp == '\0')
108
+ break; // End of exec_path reached.
120
109
  }
121
- if (cp == &procargs[size]) {
110
+
111
+ if (cp == &procargs[size])
122
112
  goto ERROR_B;
123
- }
124
113
 
125
- /* Skip trailing '\0' characters. */
126
- for (; cp < &procargs[size]; cp++) {
127
- if (*cp != '\0') {
128
- /* Beginning of first argument reached. */
129
- break;
130
- }
114
+ // Skip trailing '\0' characters.
115
+ for (; cp < &procargs[size]; cp++){
116
+ if (*cp != '\0')
117
+ break; // Beginning of first argument reached.
131
118
  }
132
- if (cp == &procargs[size]) {
119
+
120
+ if (cp == &procargs[size])
133
121
  goto ERROR_B;
134
- }
135
- /* Save where the argv[0] string starts. */
122
+
123
+ // Save where the argv[0] string starts.
136
124
  sp = cp;
137
125
 
138
126
  /*
@@ -145,13 +133,11 @@ int argv_of_pid(int pid, VALUE* v_cmdline, VALUE* v_exe, VALUE* v_environ) {
145
133
  for (np = NULL; c < nargs && cp < &procargs[size]; cp++) {
146
134
  if (*cp == '\0') {
147
135
  c++;
148
- if (np != NULL) {
149
- /* Convert previous '\0'. */
150
- *np = ' ';
151
- } else {
152
- /* *argv0len = cp - sp; */
153
- }
154
- /* Note location of current '\0'. */
136
+
137
+ if (np != NULL)
138
+ *np = ' '; // Convert previous '\0'.
139
+
140
+ // Note location of current '\0'.
155
141
  np = cp;
156
142
 
157
143
  if (!show_args) {
@@ -170,31 +156,31 @@ int argv_of_pid(int pid, VALUE* v_cmdline, VALUE* v_exe, VALUE* v_environ) {
170
156
  * sp points to the beginning of the arguments/environment string, and
171
157
  * np should point to the '\0' terminator for the string.
172
158
  */
173
- if (np == NULL || np == sp) {
174
- /* Empty or unterminated string. */
175
- goto ERROR_B;
176
- }
159
+ if (np == NULL || np == sp)
160
+ goto ERROR_B; // Empty or unterminated string.
177
161
 
178
- /* Make a copy of the string to ruby String. */
162
+ // Make a copy of the string to ruby String.
179
163
  *v_cmdline = rb_str_new2(sp);
180
164
 
181
- /* Read environment variables to ruby Hash. */
165
+ // Read environment variables to ruby Hash.
182
166
  *v_environ = rb_hash_new();
167
+
183
168
  while (cp[0]) {
184
169
  sp = strsep(&cp, "=");
185
- if (sp == NULL) {
170
+
171
+ if (!sp || !cp)
186
172
  break;
187
- }
173
+
188
174
  rb_hash_aset(*v_environ, rb_str_new2(sp), rb_str_new2(cp));
189
175
  cp += strlen(cp) + 1;
190
176
  }
191
177
 
192
- /* Clean up. */
193
- free(procargs);
178
+ // Cleanup.
179
+ ruby_xfree(procargs);
194
180
  return 0;
195
181
 
196
182
  ERROR_B:
197
- free(procargs);
183
+ ruby_xfree(procargs);
198
184
  ERROR_A:
199
185
  return -1;
200
186
  }
@@ -235,10 +221,7 @@ static VALUE pt_ps(int argc, VALUE* argv, VALUE klass){
235
221
  rb_raise(cProcTableError, "sysctl: %s", strerror(errno));
236
222
 
237
223
  // Populate the kproc buffer
238
- procs = malloc(length);
239
-
240
- if(procs == NULL)
241
- rb_raise(cProcTableError, "malloc: %s", strerror(errno));
224
+ procs = ruby_xmalloc(length);
242
225
 
243
226
  err = sysctl( (int *) name_mib, PROC_MIB_LEN, procs, &length, NULL, 0);
244
227
 
@@ -300,9 +283,9 @@ static VALUE pt_ps(int argc, VALUE* argv, VALUE klass){
300
283
  }
301
284
 
302
285
  v_groups = rb_ary_new();
303
- for (g = 0; g < procs[i].kp_eproc.e_ucred.cr_ngroups; ++g) {
286
+
287
+ for (g = 0; g < procs[i].kp_eproc.e_ucred.cr_ngroups; ++g)
304
288
  rb_ary_push(v_groups, INT2FIX(procs[i].kp_eproc.e_ucred.cr_groups[g]));
305
- }
306
289
 
307
290
  v_pstruct = rb_struct_new(
308
291
  sProcStruct,
@@ -357,7 +340,8 @@ static VALUE pt_ps(int argc, VALUE* argv, VALUE klass){
357
340
  rb_ary_push(v_array, v_pstruct);
358
341
  }
359
342
 
360
- if(procs) free(procs);
343
+ if(procs)
344
+ free(procs);
361
345
 
362
346
  if(!rb_block_given_p()){
363
347
  if(NIL_P(v_pid))
@@ -415,10 +399,8 @@ void Init_proctable(){
415
399
  /* There is no constructor */
416
400
  rb_funcall(cProcTable, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
417
401
 
418
- /* Constants */
419
-
420
- /* 0.9.6: The version of the sys-proctable library */
421
- rb_define_const(cProcTable, "VERSION", rb_str_new2(SYS_PROCTABLE_VERSION));
402
+ /* 0.9.8: The version of the sys-proctable library */
403
+ rb_define_const(cProcTable, "VERSION", rb_str_new2("0.9.8"));
422
404
 
423
405
  /* Structs */
424
406
 
@@ -0,0 +1,6 @@
1
+ module Sys
2
+ class ProcTable
3
+ # The version of the sys-proctable library
4
+ VERSION = '0.9.8'
5
+ end
6
+ end
@@ -2,11 +2,11 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-proctable'
5
- spec.version = '0.9.6'
5
+ spec.version = '0.9.8'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Artistic 2.0'
8
8
  spec.email = 'djberg96@gmail.com'
9
- spec.homepage = 'http://www.rubyforge.org/projects/sysutils'
9
+ spec.homepage = 'http://github.com/djberg96/sys-proctable'
10
10
  spec.platform = Gem::Platform::CURRENT # Probably altered by Rake task
11
11
  spec.summary = 'An interface for providing process table information'
12
12
  spec.test_files = ['test/test_sys_proctable_all.rb']
@@ -15,6 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.files = [
16
16
  'benchmarks/bench_ps.rb',
17
17
  'examples/example_ps.rb',
18
+ 'lib/sys/proctable/version.rb',
18
19
  'lib/sys/top.rb',
19
20
  'CHANGES',
20
21
  'MANIFEST',
@@ -23,7 +24,6 @@ Gem::Specification.new do |spec|
23
24
  'sys-proctable.gemspec'
24
25
  ]
25
26
 
26
- spec.rubyforge_project = 'sysutils'
27
27
  spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/top.txt']
28
28
 
29
29
  spec.add_development_dependency('test-unit')
@@ -19,7 +19,7 @@ class TC_ProcTable_All < Test::Unit::TestCase
19
19
  end
20
20
 
21
21
  def test_version
22
- assert_equal('0.9.6', ProcTable::VERSION)
22
+ assert_equal('0.9.8', ProcTable::VERSION)
23
23
  end
24
24
 
25
25
  def test_fields
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-proctable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6
4
+ version: 0.9.8
5
5
  platform: universal-darwin
6
6
  authors:
7
7
  - Daniel J. Berger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-24 00:00:00.000000000 Z
11
+ date: 2015-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
@@ -64,12 +64,13 @@ files:
64
64
  - examples/example_ps.rb
65
65
  - ext/darwin/extconf.rb
66
66
  - ext/darwin/sys/proctable.c
67
+ - lib/sys/proctable/version.rb
67
68
  - lib/sys/top.rb
68
69
  - sys-proctable.gemspec
69
70
  - test/test_sys_proctable_all.rb
70
71
  - test/test_sys_proctable_darwin.rb
71
72
  - test/test_sys_top.rb
72
- homepage: http://www.rubyforge.org/projects/sysutils
73
+ homepage: http://github.com/djberg96/sys-proctable
73
74
  licenses:
74
75
  - Artistic 2.0
75
76
  metadata: {}
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  - !ruby/object:Gem::Version
89
90
  version: '0'
90
91
  requirements: []
91
- rubyforge_project: sysutils
92
+ rubyforge_project:
92
93
  rubygems_version: 2.4.5
93
94
  signing_key:
94
95
  specification_version: 4