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.


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

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


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

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

#add_dup(fileno, new_fileno) ⇒ Object


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

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


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

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

#freeObject


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

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

#to_ptrObject


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

def to_ptr
  @ptr
end