Module: Seccomp::Notify::FdPassing

Defined in:
lib/seccomp/notify/fd_passing.rb

Class Method Summary collapse

Class Method Details

.recv_fd(socket, timeout: 10) ⇒ Object

Raises:

  • (Timeout::Error)


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/seccomp/notify/fd_passing.rb', line 15

def recv_fd(socket, timeout: 10)
  raise Timeout::Error, "timed out waiting for listener fd" unless IO.select([socket], nil, nil, timeout)

  _message, _address, _flags, control = socket.recvmsg(1, 0, 64, scm_rights: true)
  raise EOFError, "message did not contain a file descriptor" unless control

  io = control.unix_rights.first
  raise EOFError, "message did not contain a file descriptor" unless io

  io
end

.send_fd(socket, io) ⇒ Object



11
12
13
# File 'lib/seccomp/notify/fd_passing.rb', line 11

def send_fd(socket, io)
  socket.send_io(io)
end