Sha256: 46afb9062262cb923e13b783e4d61d9c2468066343d7668cbdd82784c1c6f380

Contents?: true

Size: 619 Bytes

Versions: 6

Compression:

Stored size: 619 Bytes

Contents

# This file is only available on BSD/Darwin systems.

module RubySL
  module Socket
    module Foreign
      attach_function :_getpeereid,
        :getpeereid, [:int, :pointer, :pointer], :int

      def self.getpeereid(descriptor)
        euid = Foreign.memory_pointer(:int)
        egid = Foreign.memory_pointer(:int)

        begin
          res = _getpeereid(descriptor, euid, egid)

          if res == 0
            [euid.read_int, egid.read_int]
          else
            Errno.handle('getpeereid(3)')
          end
        ensure
          euid.free
          egid.free
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubysl-socket-2.2.1 lib/rubysl/socket/bsd.rb
rubysl-socket-2.2 lib/rubysl/socket/bsd.rb
rubysl-socket-2.1.3 lib/rubysl/socket/bsd.rb
rubysl-socket-2.1.2 lib/rubysl/socket/bsd.rb
rubysl-socket-2.1.1 lib/rubysl/socket/bsd.rb
rubysl-socket-2.1.0 lib/rubysl/socket/bsd.rb