Method: LinuxStat::ProcessInfo.process_name
- Defined in:
- lib/linux_stat/process_info.rb
.process_name(pid = $$) ⇒ Object
process_name(pid = $$)
It shows the filename of the command Sometimes the filename is stripped
Where pid is the process ID.
By default it is the id of the current process ($$)
It retuns the total command name of the process.
The output is String. For example:
LinuxStat::ProcessInfo.process_name
"ruby"
If the info isn’t available it will return an empty frozen String.
112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/linux_stat/process_info.rb', line 112 def process_name(pid = $$) file = "/proc/#{pid}/stat".freeze return command_name unless File.readable?(file) name = IO.read(file).split(/(\(.*\))/) &.[](1) &.[](1..-2) if name && name.length > 0 && name.length < 15 name else command_name end end |