YkLib 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +6 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +7 -0
  7. data/Gemfile.lock +34 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +44 -0
  10. data/Rakefile +6 -0
  11. data/YkLib.gemspec +29 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/lib/YkLib/Yk/__advance__.rb +151 -0
  15. data/lib/YkLib/Yk/__defun__.rb +44 -0
  16. data/lib/YkLib/Yk/__hook__.rb +244 -0
  17. data/lib/YkLib/Yk/__minmax__.rb +123 -0
  18. data/lib/YkLib/Yk/__stdlog.rb +329 -0
  19. data/lib/YkLib/Yk/adhocLiterals/email.rb +119 -0
  20. data/lib/YkLib/Yk/adhocLiterals/path.rb +402 -0
  21. data/lib/YkLib/Yk/adhocLiterals/tag.rb +19 -0
  22. data/lib/YkLib/Yk/adhocLiterals/url.rb +36 -0
  23. data/lib/YkLib/Yk/adhocLiterals.rb +199 -0
  24. data/lib/YkLib/Yk/auto_escseq.rb +5 -0
  25. data/lib/YkLib/Yk/auto_pstore.rb +179 -0
  26. data/lib/YkLib/Yk/bsearch.rb +120 -0
  27. data/lib/YkLib/Yk/clambda.rb +309 -0
  28. data/lib/YkLib/Yk/confLine.rb +423 -0
  29. data/lib/YkLib/Yk/create_tty_width_available.rb +24 -0
  30. data/lib/YkLib/Yk/crypt.rb +26 -0
  31. data/lib/YkLib/Yk/debug2 +1 -0
  32. data/lib/YkLib/Yk/debug2.rb +473 -0
  33. data/lib/YkLib/Yk/debugout.rb +139 -0
  34. data/lib/YkLib/Yk/email_tz.rb +533 -0
  35. data/lib/YkLib/Yk/enum_expect.rb +170 -0
  36. data/lib/YkLib/Yk/errlog.rb +5 -0
  37. data/lib/YkLib/Yk/escseq.rb +59 -0
  38. data/lib/YkLib/Yk/eval_alt.rb +281 -0
  39. data/lib/YkLib/Yk/expector.rb +93 -0
  40. data/lib/YkLib/Yk/fetch.rb +556 -0
  41. data/lib/YkLib/Yk/fetch_old.rb +290 -0
  42. data/lib/YkLib/Yk/fib.rb +158 -0
  43. data/lib/YkLib/Yk/file_aux.rb +843 -0
  44. data/lib/YkLib/Yk/file_aux2.rb +919 -0
  45. data/lib/YkLib/Yk/file_aux_old.rb +160 -0
  46. data/lib/YkLib/Yk/filemod.rb +19 -0
  47. data/lib/YkLib/Yk/force_escseq.rb +3 -0
  48. data/lib/YkLib/Yk/generator__.rb +144 -0
  49. data/lib/YkLib/Yk/generator__.rb.org +139 -0
  50. data/lib/YkLib/Yk/indenter/argless_case.rb +46 -0
  51. data/lib/YkLib/Yk/indenter/each_token.rb +671 -0
  52. data/lib/YkLib/Yk/indenter/free_case.rb +313 -0
  53. data/lib/YkLib/Yk/indenter/if_less.rb +53 -0
  54. data/lib/YkLib/Yk/indenter/independent_ensure.rb +23 -0
  55. data/lib/YkLib/Yk/indenter/independent_rescue.rb +23 -0
  56. data/lib/YkLib/Yk/indenter/operand_circumflex.rb +0 -0
  57. data/lib/YkLib/Yk/indenter/operand_period.rb +16 -0
  58. data/lib/YkLib/Yk/indenter/parenless_and.rb +37 -0
  59. data/lib/YkLib/Yk/indenter/post_test.rb +48 -0
  60. data/lib/YkLib/Yk/indenter/token.rb +1525 -0
  61. data/lib/YkLib/Yk/indenter.rb +1382 -0
  62. data/lib/YkLib/Yk/inot.rb +265 -0
  63. data/lib/YkLib/Yk/intf.rb +815 -0
  64. data/lib/YkLib/Yk/io_aux.rb +1332 -0
  65. data/lib/YkLib/Yk/ioctl.rb +60 -0
  66. data/lib/YkLib/Yk/ipcc.rb +87 -0
  67. data/lib/YkLib/Yk/ipcountry.rb +207 -0
  68. data/lib/YkLib/Yk/ipv4adr.rb +318 -0
  69. data/lib/YkLib/Yk/localmail.rb +276 -0
  70. data/lib/YkLib/Yk/method_chain.rb +359 -0
  71. data/lib/YkLib/Yk/misc_tz.rb +1716 -0
  72. data/lib/YkLib/Yk/missing_method.rb +50 -0
  73. data/lib/YkLib/Yk/mojiConv.rb +257 -0
  74. data/lib/YkLib/Yk/nostdlog.rb +4 -0
  75. data/lib/YkLib/Yk/on_marshal.rb +20 -0
  76. data/lib/YkLib/Yk/overrider.rb +47 -0
  77. data/lib/YkLib/Yk/path.rb +293 -0
  78. data/lib/YkLib/Yk/path_aux.rb +883 -0
  79. data/lib/YkLib/Yk/path_aux_alt.rb +0 -0
  80. data/lib/YkLib/Yk/path_rep.rb +1267 -0
  81. data/lib/YkLib/Yk/pg_setup.rb +917 -0
  82. data/lib/YkLib/Yk/procinfo.rb +314 -0
  83. data/lib/YkLib/Yk/proclist.rb +492 -0
  84. data/lib/YkLib/Yk/property.rb +863 -0
  85. data/lib/YkLib/Yk/ranger.rb +606 -0
  86. data/lib/YkLib/Yk/resolv_tz.rb +88 -0
  87. data/lib/YkLib/Yk/rlprompt.rb +73 -0
  88. data/lib/YkLib/Yk/rootexec.rb +48 -0
  89. data/lib/YkLib/Yk/rpm-packageproxy.rb +784 -0
  90. data/lib/YkLib/Yk/rpm-packageproxy2.rb +1430 -0
  91. data/lib/YkLib/Yk/rwhen.rb +21 -0
  92. data/lib/YkLib/Yk/selector.rb +124 -0
  93. data/lib/YkLib/Yk/set.rb +170 -0
  94. data/lib/YkLib/Yk/shellquote.rb +300 -0
  95. data/lib/YkLib/Yk/sio.rb +1001 -0
  96. data/lib/YkLib/Yk/sio0.rb +835 -0
  97. data/lib/YkLib/Yk/sio_aux.rb +1524 -0
  98. data/lib/YkLib/Yk/sio_inot.rb +86 -0
  99. data/lib/YkLib/Yk/sock_aux.rb +42 -0
  100. data/lib/YkLib/Yk/spipe.rb +843 -0
  101. data/lib/YkLib/Yk/sql_table.rb +565 -0
  102. data/lib/YkLib/Yk/stdlog.rb +4 -0
  103. data/lib/YkLib/Yk/syscommand.rb +173 -0
  104. data/lib/YkLib/Yk/sysinit.rb +75 -0
  105. data/lib/YkLib/Yk/ttyFontWidth.rb +46113 -0
  106. data/lib/YkLib/Yk/tty_char.dump +0 -0
  107. data/lib/YkLib/Yk/tty_char.rb +47 -0
  108. data/lib/YkLib/Yk/tty_char_create.rb +437031 -0
  109. data/lib/YkLib/Yk/tty_char_static.rb +437016 -0
  110. data/lib/YkLib/Yk/tty_rewrite.rb +142 -0
  111. data/lib/YkLib/Yk/tty_str.rb +461 -0
  112. data/lib/YkLib/Yk/tty_width.dat.rb +114 -0
  113. data/lib/YkLib/Yk/tty_width.rb +180 -0
  114. data/lib/YkLib/Yk/tty_width_available +569 -0
  115. data/lib/YkLib/Yk/tty_width_list +0 -0
  116. data/lib/YkLib/Yk/tty_width_list.linux +280 -0
  117. data/lib/YkLib/Yk/tty_width_list.windows +324 -0
  118. data/lib/YkLib/Yk/tz_tty +0 -0
  119. data/lib/YkLib/Yk/tz_tty.rb +0 -0
  120. data/lib/YkLib/Yk/uprepos.rb +94 -0
  121. data/lib/YkLib/Yk/userinfo.rb +91 -0
  122. data/lib/YkLib/Yk/with.rb +109 -0
  123. data/lib/YkLib/version.rb +3 -0
  124. data/lib/YkLib.rb +6 -0
  125. metadata +170 -0
@@ -0,0 +1,492 @@
1
+ #
2
+
3
+
4
+ require 'time'
5
+ require 'Yk/misc_tz'
6
+ require 'Yk/path_aux'
7
+ require 'Yk/shellquote'
8
+
9
+
10
+ class ProcList
11
+ INTPRLIST = ["sh", "bash", "python", "ruby", "supervise", "rwhen", "perl" ]
12
+ private
13
+ class HashArr < Hash
14
+ def insert (k, item)
15
+ (self[k] ||= []).push item
16
+ end
17
+ end
18
+ class ProcElem
19
+ attr :pid
20
+ attr :ppid
21
+ attr :startTime
22
+ attr :command
23
+ attr :prog
24
+ attr :progBase
25
+ attr :childList
26
+ attr :status
27
+ attr :uid
28
+ def children
29
+ childList
30
+ end
31
+ attr :parent, true
32
+ attr :mem
33
+ attr :interpreter
34
+ attr :interpreterBase
35
+ def kill (sig = :TERM)
36
+ Process.kill sig, pid
37
+ end
38
+ if CYGWIN
39
+ @@timebase = Time.now.to_f - "/proc/uptime".read.split[0].to_i
40
+ else
41
+ @@timebase = `cat /proc/stat`.each_line{|e| break(e) if e =~ /^btime\s+/ }.split[1].to_i
42
+ end
43
+ if CYGWIN
44
+ @@memTotal = "/proc/meminfo".readlines.find{|e| e =~ /^MemTotal:/}.split[1].to_i
45
+ end
46
+ def initialize (ln)
47
+ if ln.is_a? String
48
+ if !CYGWIN
49
+ if ln =~ /\s*(\d+)\s+(\d+)\s+(\w+\s+\w+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+(.*)/
50
+ @pid = $1.to_i
51
+ @ppid = $2.to_i
52
+ @startTime = Time.parse($3)
53
+ @cpuTime =$5
54
+ @status =$4
55
+ @mem = $6
56
+ @uid = $7.to_i
57
+ @command = $8.chomp
58
+ if @cpuTime =~ /:/
59
+ r = ($`.to_i * 60 + $'.to_i) / (Time.now - @startTime).to_f
60
+ @cpuTime = sprintf "%2.2f", r * 100
61
+ end
62
+ else
63
+ raise Exception.new("cannot interpret ps output")
64
+ end
65
+ else
66
+ if ln =~ /\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([^\s]+)\s+(\d+)\s(........)\s(.*)/
67
+ @pid = $1.to_i
68
+ @ppid = $2.to_i
69
+ @pgid = $3.to_i
70
+ @winpid = $4.to_i
71
+ @tty = $5
72
+ @uid = $6.to_i
73
+ statusLines = "/proc/#{@pid}/status".readlines
74
+ if statusLines.size > 0
75
+ @mem = sprintf "%2.1f", ("/proc/#{@pid}/status".readlines.find{|e| e =~ /VmRSS/}.split[1].to_f / @@memTotal) * 100.0
76
+ @status = (stArr = "/proc/#{@pid}/stat".read.split)[2]
77
+ @cpuTime = (stArr[13].to_f + stArr[14].to_f)/1000
78
+ @cpuTime = sprintf("%3d:%02d", @cpuTime / 60, @cpuTime % 60)
79
+ @startTime = Time.at(@@timebase + (stArr[21].to_i / 1000.0))
80
+ if @cpuTime =~ /:/
81
+ r = ($`.to_i * 60 + $'.to_i) / (Time.now - @startTime).to_f
82
+ @cpuTime = sprintf "%2.2f", r * 100
83
+ end
84
+ @command = (IO.read("/proc/#{@pid}/cmdline").chomp.gsub(/\0/ ,' ')) rescue $8.chomp
85
+ else
86
+ @mem = "n/a"
87
+ @status = "n/a"
88
+ @cpuTime = "n/a "
89
+ @startTime = "/proc/#{@pid}".ctime
90
+ @command = "/proc/#{@pid}/exename".read
91
+ end
92
+ else
93
+ raise Exception.new("cannot interpret ps output")
94
+ end
95
+ end
96
+ @fd_cnt = 0
97
+ begin
98
+ Dir.foreach "/proc/#{@pid}/fd" do |ent|
99
+ @fd_cnt += 1 if ent =~ /^\d+$/
100
+ end
101
+ @fd_cnt = sprintf "%3d", @fd_cnt
102
+ rescue Errno::EACCES
103
+ @fd_cnt = " - "
104
+ rescue Errno::ENOENT
105
+ @fd_cnt = " - "
106
+ end
107
+ if false
108
+ cmdArgs = IO.read("/proc/#{@pid}/cmdline").chomp.split(/\0/) rescue []
109
+ firstFileArg = true
110
+ cmdArgs.each_index do |i|
111
+ if cmdArgs[i].relative?
112
+ if i == 0
113
+ begin
114
+ cmdArgs[i] = "/proc/#{@pid}/exe".readlink.chomp
115
+ rescue
116
+ end
117
+ elsif INTPRLIST.include? cmdArgs[0].basename
118
+ if cmdArgs[i] !~ /^\-/ && firstFileArg
119
+ firstFileArg = true
120
+ cwd = "/proc/#{@pid}/cwd".readlink.chomp rescue nil
121
+ if cwd
122
+ cmdArgs[i] = (cwd / cmdArgs[i]).normalize_path
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
128
+ if cmdArgs.size > 1
129
+ tmp = cmdArgs.condSQuote
130
+ tmp.gsub! /\s+/, ' '
131
+ tmp.gsub! /[\x00-\x1f]/, ''
132
+ if tmp != ""
133
+ @command = tmp
134
+ end
135
+ elsif cmdArgs.size == 1
136
+ if (tmp = cmdArgs[0].strip) != ""
137
+ @command = tmp
138
+ end
139
+ end
140
+ end
141
+ end
142
+ c = @command
143
+ @prog = @command[/[^\s]+/]
144
+ @progBase = File.basename(@prog)
145
+ if INTPRLIST.include?(@progBase)
146
+ @interpreter = @prog
147
+ @interpreterBase = @progBase
148
+ carr = @command.split /\s+/
149
+ if tmp = carr[1..-1].find{ |e| e[0] != ?- && e !~ /^(\d|\W)+$/}
150
+ @prog = tmp
151
+ @progBase = File.basename(@prog)
152
+ end
153
+ end
154
+ if Time.now - @startTime < 3600 * 24
155
+ @startTimeF = @startTime.strftime("%H:%M:%S")
156
+ else
157
+ @startTimeF = @startTime.strftime("%m/%d %a")[0..-2]
158
+ end
159
+ @childList = []
160
+ end
161
+ def self.headLine
162
+ if !CYGWIN
163
+ " PID STARTTIME STAT CPU MEM FD COMMAND\n"
164
+ else
165
+ " PID STARTTIME WPID CPU MEM FD COMMAND\n"
166
+ end
167
+ end
168
+ def prInfo
169
+ if !CYGWIN
170
+ #sprintf("%5d %s %4s %6s %4s", @pid, @startTime.strftime("%m-%d %H:%M:%S"), @status, @cpuTime, @mem)
171
+ sprintf("%5d %s %-4s %6s %4s %3s", @pid, @startTimeF, @status, @cpuTime, @mem, @fd_cnt)
172
+ else
173
+ sprintf("%5d %s %5d %6s %4s %3s", @pid, @startTimeF, @winpid, @cpuTime, @mem, @fd_cnt)
174
+ #sprintf("%5d %s", @pid, @startTime.strftime("%m-%d %H:%M:%S"))
175
+ end
176
+ end
177
+ def hasDescendantsIn? (progs)
178
+ if progs.include? self
179
+ true
180
+ else
181
+ childList.each do |e|
182
+ if e.hasDescendantsIn? progs
183
+ return true
184
+ end
185
+ end
186
+ false
187
+ end
188
+ end
189
+ def getCList (progs, inChild)
190
+ if inChild
191
+ childList
192
+ else
193
+ childList.select do |e|
194
+ e.hasDescendantsIn? progs
195
+ end
196
+ end
197
+ end
198
+ def format (w, progs, preInd = "", lst = true, inChild = false, &bl)
199
+ def fmt (w, ln, cont)
200
+ if cont.size >= w - 10
201
+ cont = cont[0 ... w - 10]
202
+ end
203
+ ln = ln.chomp
204
+ ln.gsub! /\t/, " "
205
+ if w == nil || w == 0
206
+ return ln + "\n"
207
+ end
208
+ if ln.size < w
209
+ ln += "\n"
210
+ elsif ln.size == w
211
+ ln
212
+ else
213
+ ln[0...w] + fmt(w, cont + ln[w ... ln.size].strip, cont)
214
+ end
215
+ end
216
+ inChild ||= progs.include? self
217
+ ln = prInfo
218
+ cont = " " * prInfo.size
219
+ cList = getCList(progs, inChild)
220
+ if preInd == ""
221
+ if cList.size > 0
222
+ ln += " -+ "
223
+ cont += (lst ? " | " : "| | ") + " " * (command[/[^\s\/]+/].size + 1)
224
+ else
225
+ ln += " -- "
226
+ cont += (lst ? " " : "| ") + " " * (command[/[^\s\/]+/].size + 1)
227
+ end
228
+ else
229
+ if cList.size > 0
230
+ ln += preInd + " " + (lst ? "`" : "|") + "-+ "
231
+ cont += preInd + (lst ? " | " : " | | ") + " " * (command[/[^\s\/]+/].size + 1)
232
+ else
233
+ ln += preInd + " " + (lst ? "`" : "|") + "-- "
234
+ cont += preInd + (lst ? " " : " | ") + " " * (command[/[^\s\/]+/].size + 1)
235
+ end
236
+ end
237
+ ln += command
238
+ ln = fmt(w, ln, cont)
239
+ if bl
240
+ bl.call self, ln
241
+ end
242
+ cLn = ""
243
+ if preInd == ""
244
+ nPreInd = preInd + (!lst ? "|" : " ")
245
+ else
246
+ nPreInd = preInd + (!lst ? " |" : " ")
247
+ end
248
+ cList.each_index do |i|
249
+ nLst = i == cList.size - 1
250
+ cLn += cList[i].format(w, progs, nPreInd, nLst, inChild, &bl)
251
+ end
252
+ if inChild || cLn != ""
253
+ ln + cLn
254
+ else
255
+ ""
256
+ end
257
+ end
258
+ def family
259
+ if !defined? @family
260
+ @family = [self]
261
+ childList.each do |e|
262
+ @family.push *e.family
263
+ end
264
+ end
265
+ @family
266
+ end
267
+ def hasMember (m)
268
+ family.include? m
269
+ end
270
+ def each
271
+ yield self
272
+ childList.each do |c|
273
+ c.each do |e|
274
+ yield e
275
+ end
276
+ end
277
+ end
278
+ def isFamilyOf? (arg)
279
+ if arg == self
280
+ return true
281
+ end
282
+ arg.childList.each do |e|
283
+ if isFamilyOf? e
284
+ return true
285
+ end
286
+ end
287
+ return false
288
+ end
289
+ end
290
+ def self.headLine
291
+ ProcElem.headLine
292
+ end
293
+ def initialize
294
+ @list = []
295
+ @byPid = Hash.new
296
+ @byProg = HashArr.new
297
+ @byProgBase = HashArr.new
298
+ if !CYGWIN
299
+ cmd = "ps ax --cols 10000 -eo pid,ppid,lstart,stat,bsdtime,%mem,euid,command"
300
+ else
301
+ cmd = "ps -ael"
302
+ end
303
+ IO.popen cmd do |io|
304
+ io.each_line do |ln|
305
+ if ln =~ /^\s+PID\s/
306
+ next
307
+ else
308
+ if io.pid.to_i == ln.strip.split[0].to_i
309
+ next
310
+ end
311
+ end
312
+ pe = ProcElem.new(ln)
313
+ @list.push pe
314
+ @byPid[pe.pid] = pe
315
+ @byProg.insert(pe.prog, pe)
316
+ @byProgBase.insert(pe.progBase, pe)
317
+ if pe.interpreter
318
+ @byProg.insert(pe.interpreter, pe)
319
+ @byProgBase.insert(pe.interpreterBase, pe)
320
+ end
321
+ end
322
+ end
323
+ @list.each do |pe|
324
+ pe.parent = @byPid[pe.ppid]
325
+ if pe.parent != nil
326
+ pe.parent.childList.push pe
327
+ end
328
+ end
329
+ end
330
+ public
331
+ def each
332
+ @list.each do |e|
333
+ yield e
334
+ end
335
+ end
336
+ def getUnique (arr)
337
+ isMember = Hash.new
338
+ arr.size.times do |i|
339
+ arr.size.times do |j|
340
+ if i != j
341
+ if arr[i].hasMember arr[j]
342
+ isMember[arr[j]] = true
343
+ end
344
+ end
345
+ end
346
+ end
347
+ ret = []
348
+ arr.each do |e|
349
+ if !isMember[e]
350
+ ret.push e
351
+ end
352
+ end
353
+ return ret
354
+ end
355
+ @@procList = ProcList.new
356
+ def prog (expr, match)
357
+ case expr
358
+ when String
359
+ arr = expr =~ /\// ? @byProg[expr] : @byProgBase[expr]
360
+ if arr == nil
361
+ return []
362
+ end
363
+ when Regexp
364
+ arr = []
365
+ @list.each do |e|
366
+ if e.command =~ expr
367
+ arr.push e
368
+ end
369
+ end
370
+ when nil
371
+ arr = @list
372
+ end
373
+ if match != nil
374
+ if match.is_a? String
375
+ a2 = []
376
+ arr.each do |e|
377
+ if e.command.include? match
378
+ a2.push e
379
+ end
380
+ end
381
+ arr = a2
382
+ elsif match.is_a? Regexp
383
+ a2 = []
384
+ arr.each do |e|
385
+ if e.command =~ match
386
+ a2.push e
387
+ end
388
+ end
389
+ arr = a2
390
+ end
391
+ end
392
+ arr
393
+ end
394
+ def pid (id)
395
+ if id.is_a?(String) || id.is_a?(Process)
396
+ id = id.to_i
397
+ end
398
+ return @byPid[id]
399
+ end
400
+ def find (*pidOrProg)
401
+ id, prg, baseComp = nil, nil, nil
402
+ pidOrProg.each do |e|
403
+ if e.is_a? Integer
404
+ id = e
405
+ end
406
+ if e.is_a? String
407
+ prg = e
408
+ if e !~ /\//
409
+ baseComp = true
410
+ else
411
+ baseComp = false
412
+ end
413
+ end
414
+ end
415
+ if id
416
+ if !(tmp = pid(id))
417
+ return nil
418
+ end
419
+ if prg
420
+ if baseComp
421
+ tmp.progBase == prg ? tmp : nil
422
+ else
423
+ tmp.prog == prg ? tmp : nil
424
+ end
425
+ else
426
+ return tmp
427
+ end
428
+ elsif prg
429
+ prog(prg, nil)[0]
430
+ else
431
+ return nil
432
+ end
433
+ end
434
+ def exist? (*pidOrProg)
435
+ find *pidOrProg
436
+ end
437
+ def ProcList.pid (id)
438
+ @@procList.pid id
439
+ end
440
+ def ProcList.current
441
+ @@procList.pid $$
442
+ end
443
+ def ProcList.parent
444
+ @@procList.pid($$).parent
445
+ end
446
+ def ProcList._findParent
447
+ pe = current
448
+ while true
449
+ if yield pe
450
+ return pe
451
+ end
452
+ pe = pe.parent
453
+ if pe == nil
454
+ break
455
+ end
456
+ end
457
+ return nil
458
+ end
459
+ def ProcList.findParent (a)
460
+ if (pid = a).is_a?(Integer) || (a.is_a?(Process) && pid = a.to_i)
461
+ return _findParent { |pe| pe.pid == pid }
462
+ else
463
+ if a !~ /\//
464
+ return _findParent { |pe| pe.progBase == a }
465
+ else
466
+ return _findParent { |pe| pe.prog == a }
467
+ end
468
+ end
469
+ end
470
+ def ProcList.prog (expr, match = nil)
471
+ @@procList.prog expr, match
472
+ end
473
+ def ProcList.independent (arr)
474
+ @@procList.getUnique arr
475
+ end
476
+ def ProcList.refresh
477
+ @@procList = ProcList.new
478
+ end
479
+ def ProcList.exist? (*pidOrPrg)
480
+ @@procList.exist?(*pidOrPrg)
481
+ end
482
+ def ProcList.find (*pidOrPrg)
483
+ @@procList.exist?(*pidOrPrg)
484
+ end
485
+ def ProcList.each
486
+ @@procList.each do |e|
487
+ yield e
488
+ end
489
+ end
490
+ end
491
+
492
+