Class: ChildProcess::Unix::PosixSpawnProcess::Argv

Inherits:
Object
  • Object
show all
Defined in:
lib/childprocess/unix/posix_spawn_process.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Argv

Returns a new instance of Argv



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/childprocess/unix/posix_spawn_process.rb', line 89

def initialize(args)
  @ptrs = args.map do |e|
    if e.include?("\0")
      raise ArgumentError, "argument cannot contain null bytes: #{e.inspect}"
    end

    FFI::MemoryPointer.from_string(e.to_s)
  end

  @ptrs << FFI::Pointer.new(0)
end

Instance Method Details

#to_ptrObject



101
102
103
104
105
106
# File 'lib/childprocess/unix/posix_spawn_process.rb', line 101

def to_ptr
  argv = FFI::MemoryPointer.new(:pointer, @ptrs.size)
  argv.put_array_of_pointer(0, @ptrs)

  argv
end