Class: ChildProcess::Unix::Lib::FileActions

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

Instance Method Summary collapse

Constructor Details

#initializeFileActions

Returns a new instance of FileActions.



99
100
101
102
# File 'lib/childprocess/unix/lib.rb', line 99

def initialize
  @ptr = FFI::MemoryPointer.new(1, Platform::SIZEOF.fetch(:posix_spawn_file_actions_t), false)
  Lib.check Lib.posix_spawn_file_actions_init(@ptr)
end

Instance Method Details

#add_close(fileno) ⇒ Object



104
105
106
107
108
109
# File 'lib/childprocess/unix/lib.rb', line 104

def add_close(fileno)
  Lib.check Lib.posix_spawn_file_actions_addclose(
    @ptr,
    fileno
  )
end

#add_dup(fileno, new_fileno) ⇒ Object



121
122
123
124
125
126
127
# File 'lib/childprocess/unix/lib.rb', line 121

def add_dup(fileno, new_fileno)
  Lib.check Lib.posix_spawn_file_actions_adddup2(
    @ptr,
    fileno,
    new_fileno
  )
end

#add_open(fileno, path, oflag, mode) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/childprocess/unix/lib.rb', line 111

def add_open(fileno, path, oflag, mode)
  Lib.check Lib.posix_spawn_file_actions_addopen(
    @ptr,
    fileno,
    path,
    oflag,
    mode
  )
end

#freeObject



129
130
131
132
# File 'lib/childprocess/unix/lib.rb', line 129

def free
  Lib.check Lib.posix_spawn_file_actions_destroy(@ptr)
  @ptr = nil
end

#to_ptrObject



134
135
136
# File 'lib/childprocess/unix/lib.rb', line 134

def to_ptr
  @ptr
end