Module: OsCtld::ContainerControl::Utils::Wall::Runner

Included in:
Commands::Stop::Runner, Commands::StopByHalt::Runner, Commands::StopRunit::Runner, Commands::Wall::Runner
Defined in:
lib/osctld/container_control/utils/wall.rb

Instance Method Summary collapse

Instance Method Details

#ct_wall(message) ⇒ Process::Status

Parameters:

  • message (String)

Returns:

  • (Process::Status)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/osctld/container_control/utils/wall.rb', line 22

def ct_wall(message)
  pid = lxc_ct.attach do
    UtmpReader.read_utmp_fhs(max_entries: 32) do |entry|
      next if entry.record_type != :user_process

      begin
        write_to_tty(File.join('/dev', entry.ut_line), message)
      rescue SystemCallError
        next
      end
    end
  end

  begin
    Process.wait(pid)
    $?
  rescue Errno::ECHILD
    1
  end
end

#write_to_tty(path, message) ⇒ Object

Parameters:

  • path (String)

    pty device

  • message (String)


45
46
47
# File 'lib/osctld/container_control/utils/wall.rb', line 45

def write_to_tty(path, message)
  File.write(path, message)
end