Class: ChildProcess::Unix::PosixSpawnProcess::Envp
- Inherits:
-
Object
- Object
- ChildProcess::Unix::PosixSpawnProcess::Envp
- Defined in:
- lib/childprocess/unix/posix_spawn_process.rb
Overview
Argv
Instance Method Summary collapse
-
#initialize(env) ⇒ Envp
constructor
A new instance of Envp.
- #to_ptr ⇒ Object
Constructor Details
#initialize(env) ⇒ Envp
Returns a new instance of Envp.
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/childprocess/unix/posix_spawn_process.rb', line 110 def initialize(env) @ptrs = env.map do |key, val| next if val.nil? if key =~ /=|\0/ || val.to_s.include?("\0") raise InvalidEnvironmentVariable, "#{key.inspect} => #{val.to_s.inspect}" end FFI::MemoryPointer.from_string("#{key}=#{val.to_s}") end.compact @ptrs << FFI::Pointer.new(0) end |
Instance Method Details
#to_ptr ⇒ Object
124 125 126 127 128 129 |
# File 'lib/childprocess/unix/posix_spawn_process.rb', line 124 def to_ptr env = FFI::MemoryPointer.new(:pointer, @ptrs.size) env.put_array_of_pointer(0, @ptrs) env end |