Module: Cline::Utils::Os::Linux

Includes:
Logger
Defined in:
lib/cline/utils/os/linux.rb

Overview

OS utils for host OS linux

Instance Method Summary collapse

Methods included from Logger

#log_debug, sanitize_pty_output

Instance Method Details

#cline_exeArray<String>

Returns The Cline executable command line (can also have some arguments).

Returns:

  • (Array<String>)

    The Cline executable command line (can also have some arguments)



27
28
29
# File 'lib/cline/utils/os/linux.rb', line 27

def cline_exe
  ['cline']
end

#kill(pid) ⇒ Object

Kill a process Handles errors gracefully in case the process has already disappeared.

Parameters:

  • pid (Integer)

    Process to kill



19
20
21
22
23
24
# File 'lib/cline/utils/os/linux.rb', line 19

def kill(pid)
  Process.kill('TERM', pid)
rescue Errno::ESRCH
  # Could be that the process naturally died before we interrupted it
  log_debug "Process #{pid} was already killed"
end

#max_cmd_lengthInteger

Returns Maximum length a command line can have.

Returns:

  • (Integer)

    Maximum length a command line can have



37
38
39
# File 'lib/cline/utils/os/linux.rb', line 37

def max_cmd_length
  @max_cmd_length ||= Integer(`getconf ARG_MAX`.strip)
end

#user_app_data_dirString

Returns The user applications data directory.

Returns:

  • (String)

    The user applications data directory



32
33
34
# File 'lib/cline/utils/os/linux.rb', line 32

def user_app_data_dir
  "#{user_home_dir}/.config"
end

#user_home_dirString

Get the user home directory path

Returns:

  • (String)

    Normalized absolute path to user home directory



11
12
13
# File 'lib/cline/utils/os/linux.rb', line 11

def user_home_dir
  @user_home_dir ||= `eval echo ~$USER`.strip
end