Class: PosixPsutil::PlatformSpecificProcess

Inherits:
PosixPsutil::PsutilHelper::Processes show all
Includes:
NetworkConstance, PsutilHelper
Defined in:
lib/posixpsutil/linux/process.rb

Constant Summary collapse

@@terminal_map =

for class scope variable which should be memorized

{}
@@boot_time =
nil

Constants included from NetworkConstance

NetworkConstance::AF_INET, NetworkConstance::AF_INET6, NetworkConstance::AF_UNIX, NetworkConstance::CONN_CLOSE, NetworkConstance::CONN_CLOSE_WAIT, NetworkConstance::CONN_CLOSING, NetworkConstance::CONN_ESTABLISHED, NetworkConstance::CONN_FIN_WAIT1, NetworkConstance::CONN_FIN_WAIT2, NetworkConstance::CONN_LAST_ACK, NetworkConstance::CONN_LISTEN, NetworkConstance::CONN_NONE, NetworkConstance::CONN_SYN_RECV, NetworkConstance::CONN_SYN_SENT, NetworkConstance::CONN_TIME_WAIT, NetworkConstance::SOCK_DGRAM, NetworkConstance::SOCK_STREAM, NetworkConstance::TCP_STATUSES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PsutilHelper

boot_time

Methods inherited from PosixPsutil::PsutilHelper::Processes

get_all_inodes, get_proc_inodes, pids

Constructor Details

#initialize(pid) ⇒ PlatformSpecificProcess

Returns a new instance of PlatformSpecificProcess.

Raises:

  • (ArgumentError)


86
87
88
89
90
# File 'lib/posixpsutil/linux/process.rb', line 86

def initialize(pid)
  raise ArgumentError.new("pid is illegal!") if pid.nil? || pid <= 0
  @pid = pid
  @name = nil
end

Class Method Details

.assert_process_exists(method) ⇒ Object

assert the process is existed when specific method called



599
600
601
602
603
604
605
606
607
# File 'lib/posixpsutil/linux/process.rb', line 599

def self.assert_process_exists(method)
  old_method = instance_method(method)
  define_method method do |*args, &block|
    file = "/proc/#{@pid}"
    # raise NSP if the process disappeared on us
    raise NoSuchProcess.new(pid: @pid) unless File.exists?(file)
    old_method.bind(self).call(*args, &block)
  end
end

.wrap_action_except_for(wrapper, methods) ⇒ Object



610
611
612
613
614
615
616
# File 'lib/posixpsutil/linux/process.rb', line 610

def self.wrap_action_except_for(wrapper, methods)
  methods = self.instance_methods(false) - methods
  wrapper = method(wrapper)
  methods.each do |method|
    wrapper.call(method)
  end
end

.wrap_exceptions(method) ⇒ Object

Decorator which translates Errno::ENOENT, Errno::ESRCH into AccessDenied; Errno::EPERM, Errno::EACCES into NoSuchProcess.



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/posixpsutil/linux/process.rb', line 94

def self.wrap_exceptions(method)
  old_method = instance_method(method)
  define_method method do |*args, &block|
    begin
      old_method.bind(self).call(*args, &block)
    rescue Errno::ENOENT, Errno::ESRCH
      raise NoSuchProcess.new(pid:@pid, name:@name)
    rescue Errno::EPERM, Errno::EACCES
      raise AccessDenied.new(pid: @pid, name:@name)
    end
  end
end

Instance Method Details

#cmdlineObject



107
108
109
# File 'lib/posixpsutil/linux/process.rb', line 107

def cmdline
  IO.read("/proc/#{@pid}/cmdline").split("\x00").delete_if {|x| !x}
end

#connections(interface = :inet) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/posixpsutil/linux/process.rb', line 136

def connections(interface = :inet)
  connection = Connection.new
  unless connection.tmap.key?(interface)
    raise ArgumentError.new("Unknown connection kind #{interface}") 
  end
  inodes = Processes.get_proc_inodes(@pid)
  return [] if inodes.empty?

  ret = []
  connection.tmap[interface].each do |kind|
    f, family, type = kind
    if [AF_INET, AF_INET6].include?(family)
      ret.concat(connection.process_inet("/proc/net/#{f}", 
                                         family, type, inodes, @pid))
    else
      ret.concat(connection.process_unix("/proc/net/#{f}", 
                                         family, inodes, @pid))
    end
  end
  ret.each { |conn| conn.delete_field(:pid) }
end

#cpu_affinityObject



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/posixpsutil/linux/process.rb', line 162

def cpu_affinity
  FFI::MemoryPointer.new(:pointer, 1) do |p|
    # p is an double pointer, 
    # we will malloc enough space for the pointer it holds in `get_cpu_affinity`
    cpu_count = FFI::MemoryPointer.new(:int, 1)
    status = LibPosixPsutil.get_cpu_affinity(@pid, p, cpu_count)
    case status
    when 0
      affinity = p.get_pointer(0).get_array_of_long(0, cpu_count.read_int)
      LibC.free p.get_pointer(0)
      return affinity
    when -1 # got nothing
      return []
    else # error occured
      raise SystemCallError.new('in get_cpu_affinity', status)
    end
  end
end

#cpu_affinity=(cpus) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/posixpsutil/linux/process.rb', line 181

def cpu_affinity=(cpus)
  total_cpus = CPU.cpu_count
  seq_len = cpus.size > total_cpus ? total_cpus : cpus.size
  begin
    FFI::MemoryPointer.new(:long, seq_len) do |affinity|
      affinity.write_array_of_long(cpus[0...seq_len])
      status = LibPosixPsutil.set_cpu_affinity(@pid, affinity, seq_len)
      raise SystemCallError.new('in set_cpu_affinity', status) if status != 0
    end
  # The  affinity bit mask mask contains no processors that are currently 
  # physically on the system and permitted to the thread according to any 
  # restrictions that may be imposed by the "cpuset" mechanism 
  # described in cpuset(7)
  rescue Errno::EINVAL
    cpus.each do |cpu|
      if cpu < 0 || cpu >= total_cpus
        raise ArgumentError.new
          "invalid CPU #{cpu} (choose between 0 to #{total_cpus})"
      end
    end
    raise
  end
end

#cpu_timesObject



111
112
113
114
115
116
117
118
119
# File 'lib/posixpsutil/linux/process.rb', line 111

def cpu_times
  st = IO.read("/proc/#{@pid}/stat").strip
  # ignore the first two values ("pid (exe)")
  st = st[/\) (.*$)/, 1]
  values = st.split(' ')
  utime = values[11].to_f / CLOCK_TICKS
  stime = values[12].to_f / CLOCK_TICKS
  OpenStruct.new(user:utime, system:stime)
end

#create_timeObject



121
122
123
124
125
126
127
128
129
130
# File 'lib/posixpsutil/linux/process.rb', line 121

def create_time
  if @create_time.nil?
    st = IO.read("/proc/#{@pid}/stat").strip
    st = st[/\) (.*$)/, 1]
    values = st.split(' ')
    @@boot_time = PsutilHelper::boot_time() if @@boot_time.nil?
    @create_time =  @@boot_time + values[19].to_f / CLOCK_TICKS
  end
  @create_time
end

#cwdObject



158
159
160
# File 'lib/posixpsutil/linux/process.rb', line 158

def cwd
  File.readlink("/proc/#{@pid}/cwd").sub("\x00", "")
end

#exeObject



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/posixpsutil/linux/process.rb', line 205

def exe
  begin
    # readlink() might return paths containing null bytes ('\x00').
    # Certain names have ' (deleted)' appended. Usually this is
    # bogus as the file actually exists. Either way that's not
    # important as we don't want to discriminate executables which
    # have been deleted.
    exe = File.readlink("/proc/#{@pid}/exe").split("\x00")[0]
    if exe.end_with?(' (deleted)') && !File.exists(exe)
      exe = exe[0...-10]
    end
    exe
  rescue Errno::ENOENT, Errno::ESRCH
    # no such file error; might be raised also if the
    # path actually exists for system processes with
    # low pids (about 0-20)
    if File.exists? "/proc/#{@pid}"
      return ""
    else
      raise NoSuchProcess.new(pid:@pid)
    end
    raise
  rescue Errno::EPERM, Errno::EACCES
    raise AccessDenied.new(pid:@pid, name:name())
  end
end

#gidsObject

Raises:

  • (NotImplementedError)


232
233
234
235
236
237
238
239
240
241
242
# File 'lib/posixpsutil/linux/process.rb', line 232

def gids
  IO.readlines("/proc/#{@pid}/status").each do |line|
    if line.start_with?("Gid:")
      _, real, effective, saved, _ = line.split
      return OpenStruct.new(real: real.to_i, effective: effective.to_i, 
                           saved: saved.to_i)
    end
  end
  # impossible to reach here
  raise NotImplementedError.new('line not found')
end

#io_countersObject



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/posixpsutil/linux/process.rb', line 244

def io_counters
  rcount = wcount = rbytes = wbytes = nil
  IO.readlines("/proc/#{@pid}/io").each do |line|
    if !rcount && line.start_with?("syscr")
      rcount = line.split[1] 
    elsif !wcount && line.start_with?("syscw")
      wcount = line.split[1]
    elsif !rbytes && line.start_with?("read_bytes")
      rbytes = line.split[1]
    elsif !wbytes && line.start_with?("write_bytes")
      wbytes = line.split[1]
    end
  end
  [rcount, wcount, rbytes, wbytes].each do |item|
    raise NotImplementedError.new(
      "couldn't read all necessary info from /proc/#{@pid}/io") unless item
  end
  OpenStruct.new(rcount: rcount, wcount: wcount, 
                 rbytes: rbytes, wbytes: wbytes)
end

#ioniceObject

Raises:

  • (SystemCallError)


265
266
267
268
269
270
271
# File 'lib/posixpsutil/linux/process.rb', line 265

def ionice
  ioclass = FFI::MemoryPointer.new(:int, 1)
  value = FFI::MemoryPointer.new(:int, 1)
  status = LibPosixPsutil.get_ionice(@pid, ioclass, value)
  raise SystemCallError.new('in get_ionice', status) if status != 0
  OpenStruct.new(ioclass: ioclass.read_int, value: value.read_int)
end

#memory_infoObject



306
307
308
309
310
# File 'lib/posixpsutil/linux/process.rb', line 306

def memory_info
  vms, rss = File.new("/proc/#{@pid}/statm").readline.split[0...2]
  OpenStruct.new(vms: vms.to_i * PAGE_SIZE, 
                 rss: rss.to_i * PAGE_SIZE)
end

#memory_info_exObject

| FIELD | DESCRIPTION | AKA | TOP |

============================================================

| rss | resident set size | | RES | | vms | total program size | size | VIRT | | shared | shared pages (from shared mappings) | | SHR | | text | text (‘code’) | trs | CODE | | lib | library (unused in Linux 2.6) | lrs | | | data | data + stack | drs | DATA | | dirty | dirty pages (unused in Linux 2.6) | dt | |

============================================================


323
324
325
326
327
328
# File 'lib/posixpsutil/linux/process.rb', line 323

def memory_info_ex
  info = File.new("/proc/#{@pid}/statm").readline.split[0...7]
  vms, rss, shared, text, lib, data, dirty = info.map {|i| i.to_i * PAGE_SIZE}
  OpenStruct.new(vms: vms, rss: rss, shared: shared, text: text, lib: lib,
                data: data, dirty: dirty)
end

#memory_mapsObject

Return process’s mapped memory regions as a list of nameduples. Fields are explained in ‘man proc’; here is an updated (Apr 2012) version: goo.gl/fmebo

Raises:

  • (NotImplementedError)


335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/posixpsutil/linux/process.rb', line 335

def memory_maps
  lines = IO.readlines("/proc/#{@pid}/smaps")
  return [] if lines == [] # smaps file can be empty

  blocks = []
  # the header of each section
  first_line = lines[0]

  region_data = {}
  lines.each do |line|
    fields = line.split(/\s+/, 6)
    if fields[0].end_with?(':')
      value = fields[1].to_i
      # if fields[1] can be convert to number
      if value == 0 && fields[1] != '0'
        next if fields[0].start_with?('VmFlags:')
        raise ValueError.new("don't know how to interpret line #{line}")
      end
      region_data[fields[0]] = value * 1024
    else
      # new block section
      blocks.push([first_line, Marshal.load(Marshal.dump(region_data))])
      region_data.clear
      first_line = line
    end
  end
  # deal with final section
  blocks.push([first_line, region_data])

  maps = []
  blocks.each do |header, data|
    hfields = header.split(/\s+/, 6)
    addr, perms, _, _, _, path = hfields
    # hfields may only have 5 parts
    (path.nil? || path == '')? path = '[anon]' : path.strip!
    maps.push([
      addr,
      perms,
      path,
      data.fetch('Rss:', 0),
      data.fetch('Size:', 0),
      data.fetch('Pss:', 0),
      data.fetch('Shared_Clean:', 0),
      data.fetch('Shared_Dirty:', 0),
      data.fetch('Private_Clean:', 0),
      data.fetch('Private_Dirty:', 0),
      data.fetch('Referenced:', 0),
      data.fetch('Anonymous:', 0),
      data.fetch('Swap:', 0)
    ])
  end
  maps
end

#nameObject



399
400
401
402
403
# File 'lib/posixpsutil/linux/process.rb', line 399

def name
  @name = File.new("/proc/#{@pid}/stat").readline.
    split(' ')[1][/\((.+?)\)/, 1] unless @name
  @name
end

#niceObject



405
406
407
408
409
# File 'lib/posixpsutil/linux/process.rb', line 405

def nice
  # A value in the range 19 (low priority) to -20 (high priority).
  # Use `man proc` to see the difference between priority and nice.
  IO.read("/proc/#{@pid}/stat").split[18].to_i
end

#nice=(value) ⇒ Object

Raises:

  • (SystemCallError)


411
412
413
414
415
416
417
# File 'lib/posixpsutil/linux/process.rb', line 411

def nice=(value)
  if value.to_i != value || value < -20 || value > 19
    raise ArgumentError.new("nice expected is an integer between -20 and 19, got #{value}")
  end
  status = LibPosixPsutil.set_priority(@pid, value)
  raise SystemCallError.new("in set_priority", status) if status != 0
end

#num_ctx_switchesObject

Raises:

  • (NotImplementedError)


419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/posixpsutil/linux/process.rb', line 419

def num_ctx_switches
  vol = nonvol = nil
  IO.readlines("/proc/#{@pid}/status").each do |line|
    if line.start_with?("voluntary_ctxt_switches")
      vol = line.split[1].to_i
    elsif line.start_with?("nonvoluntary_ctxt_switches")
      nonvol = line.split[1].to_i
    end

    if vol && nonvol
      return OpenStruct.new(voluntary: vol, involuntary: nonvol)
    end
  end
  msg = "    |'voluntary_ctxt_switches' and 'nonvoluntary_ctxt_switches'\n    | fields were not found in /proc/\#{@pid}/status; the kernel is \n    |probably older than 2.6.23\n  EOF\n  raise NotImplementedError.new(msg)\nend\n".gsub(/(?:^\s+\||\n)/, '')

#num_fdsObject



440
441
442
# File 'lib/posixpsutil/linux/process.rb', line 440

def num_fds
  Dir.entries("/proc/#{@pid}/fd").size - 2 # ignore '.' and '..'
end

#num_threadsObject

Raises:

  • (NotImplementedError)


444
445
446
447
448
449
# File 'lib/posixpsutil/linux/process.rb', line 444

def num_threads
  IO.readlines("/proc/#{@pid}/status").each do |line|
    return line.split[1].to_i if line.start_with?("Threads:")
  end
  raise NotImplementedError.new("line not found")
end

#open_filesObject



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/posixpsutil/linux/process.rb', line 451

def open_files
  retlist = []
  Dir.entries("/proc/#{@pid}/fd").each do |fd|
    next if fd == '.' || fd == '..'
    file = "/proc/#{@pid}/fd/#{fd}"
    if File.symlink?(file)
      begin
        file = File.readlink(file)
      rescue Errno::ENOENT, Errno::ESRCH
        # raise NSP if the process disappeared on us
        next if File.exist?("/proc/#{@pid}")
      end
      # If file is not an absolute path there's no way
      # to tell whether it's a regular file or not,
      # so we skip it. A regular file is always supposed
      # to be absolutized though.
      if file.start_with?('/') && File.file?(file) # regular file only
        retlist.push(OpenStruct.new(path: file, fd: fd.to_i))
      end
    end
  end

  retlist
end

#pmmap_ext(data) ⇒ Object

data in pmmap_ext is an Array



477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/posixpsutil/linux/process.rb', line 477

def pmmap_ext(data)
  pmmap_ext = ['addr', 'perms', 'path', 'rss', 'size', 'pss', 
               'shared_clean', 'shared_dirty', 'private_clean', 
               'private_dirty', 'referenced', 'anonymous', 'swap']
  os_list = []
  data.each do |datum|
    os = OpenStruct.new
    pmmap_ext.each_index {|i| os[pmmap_ext[i]] = datum[i]}
    os_list.push(os)
  end
  os_list
end

#pmmap_grouped(data) ⇒ Object

data in pmmap_grouped is a Hash



491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/posixpsutil/linux/process.rb', line 491

def pmmap_grouped(data)
  pmmap_grouped = ['rss', 'size', 'pss', 'shared_clean', 
                   'shared_dirty', 'private_clean', 'private_dirty', 
                   'referenced', 'anonymous', 'swap']
  os_list = []
  data.each do |k, v|
    os = OpenStruct.new
    os.path = k
    pmmap_grouped.each_index {|i| os[pmmap_grouped[i]] = v[i]}
    os_list.push(os)
  end
  os_list
end

#ppidObject

Raises:

  • (NotImplementedError)


505
506
507
508
509
510
# File 'lib/posixpsutil/linux/process.rb', line 505

def ppid
  IO.readlines("/proc/#{@pid}/status").each do |line|
    return line.split[1].to_i if line.start_with?("PPid:")
  end
  raise NotImplementedError.new("line not found")
end

#rlimit(resource, limits = nil) ⇒ Object



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'lib/posixpsutil/linux/process.rb', line 512

def rlimit(resource, limits=nil)
  if resource.is_a?(Symbol)
    unless RLIMIT.key? resource
      symbols = ":" + RLIMIT.keys.join(', :')
      msg = "Unsupported symbol :#{resource}, only support #{symbols}"
      raise ArgumentError.new(msg)
    end
    resource = RLIMIT[resource]
  end

  # if pid is 0 prlimit() applies to the calling process and
  # we don't want that
  if @pid == 0
    raise ArgumentError.new("can't use prlimit() against PID 0 process")
  end
  if limits.nil?
    # get
    # On 64-bit system, long long is the same as long, can we replace it with long?
    soft = FFI::MemoryPointer.new(:long_long, 1)
    hard = FFI::MemoryPointer.new(:long_long, 1)
    status = LibPosixPsutil.get_rlimit(@pid, resource, soft, hard)
    raise SystemCallError.new("in get_rlimit", status) if status != 0
    {:soft => soft.read_long_long, :hard => hard.read_long_long}
  else
    # set
    if limits.is_a?(Hash) && limits.key?(:soft) && limits.key?(:hard)
      status = LibPosixPsutil.set_rlimit(@pid, resource, 
                                         limits[:soft], limits[:hard])
      raise SystemCallError.new("in set_rlimit", status) if status != 0
      limits
    else
      msg = "second argument must be a {:soft, :hard} Hash"
      raise ArgumentError.new(msg)
    end
  end 

end

#set_ionice(ioclass, value) ⇒ Object

Raises:

  • (SystemCallError)


273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/posixpsutil/linux/process.rb', line 273

def set_ionice(ioclass, value)
  ioclass ||= IOPRIO_CLASS_NONE

  if ioclass.is_a?(Symbol)
    unless IOPRIO_CLASS.key? ioclass
      symbols = ":" + IOPRIO_CLASS.keys.join(', :')
      msg = "Unsupported symbol :#{ioclass}, only support #{symbols}"
      raise ArgumentError.new(msg)
    end
    ioclass = IOPRIO_CLASS[ioclass]
  end

  case ioclass
  when IOPRIO_CLASS_NONE
    raise ArgumentError.new("can't specify value with #{ioclass}") if value
    value = 0
  when IOPRIO_CLASS_RT, IOPRIO_CLASS_BE
    value = 4 if value.nil?
  when IOPRIO_CLASS_IDLE
    raise ArgumentError.new("can't specify value with #{ioclass}") if value
    value = 0
  else
    msg = "ioclass argument expected is an integer between 0 and 3, got #{ioclass}"
    raise ArgumentError.new(msg)
  end
  if value < 0 || value > 7 || value.to_i != value
    msg = "value argument expected is an integer between 0 and 7, got #{value}"
    raise ArgumentError.new(msg)
  end
  status = LibPosixPsutil.set_ionice(@pid, ioclass, value)
  raise SystemCallError.new('in set_ionice', status) if status != 0
end

#statusObject



550
551
552
553
554
555
556
# File 'lib/posixpsutil/linux/process.rb', line 550

def status
  PROC_STATUSES.default = '?'
  IO.readlines("/proc/#{@pid}/status").each do |line|
    # PROC_STATUSES will return '?' if given key is not existed
    return PROC_STATUSES[line.split[1]] if line.start_with?('State:')
  end
end

#terminalObject



558
559
560
561
562
# File 'lib/posixpsutil/linux/process.rb', line 558

def terminal
  tmap = get_terminal_map
  tty_nr = IO.read("/proc/#{@pid}/stat").split(' ')[6].to_i
  tmap[tty_nr] # if tty_nr is not a key of tmap, retun nil
end

#threadsObject



564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/posixpsutil/linux/process.rb', line 564

def threads
  thread_ids = Dir.entries("/proc/#{@pid}/task").sort - ['.', '..']
  retlist = []
  thread_ids.each do |id|
    begin
      st = IO.read("/proc/#{@pid}/task/#{id}/stat").strip
      st = st[/\) (.*$)/, 1]
      values = st.split(' ')
      utime = values[11].to_f / CLOCK_TICKS
      stime = values[12].to_f / CLOCK_TICKS
      retlist.push(OpenStruct.new(thread_id: id, 
                                  user_time: utime, system_time: stime))
    rescue Errno::ENOENT
      # check if process disappeared on us
      # may raise NoSuchProcess
      raise NoSuchProcess.new(pid: @pid) unless File.exists?("/proc/#{@pid}")
      next
    end
  end
  retlist
end

#time_usedObject



132
133
134
# File 'lib/posixpsutil/linux/process.rb', line 132

def time_used
  (Time.now.to_f - create_time).round 2
end

#uidsObject

Raises:

  • (NotImplementedError)


586
587
588
589
590
591
592
593
594
595
596
# File 'lib/posixpsutil/linux/process.rb', line 586

def uids
  IO.readlines("/proc/#{@pid}/status").each do |line|
    if line.start_with?("Uid:")
      _, real, effective, saved, _ = line.split
      return OpenStruct.new(real: real.to_i, effective: effective.to_i, 
                           saved: saved.to_i)
    end
  end
  # impossible to reach here
  raise NotImplementedError.new('line not found')
end