Class: Spoon::SpawnAttributes

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

Constant Summary collapse

SIZE =
FFI::Platform.mac? ? FFI.type_size(:pointer) : 128

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpawnAttributes

Returns a new instance of SpawnAttributes.

Raises:

  • (SystemCallError)


56
57
58
59
60
# File 'lib/spoon/unix.rb', line 56

def initialize
  @pointer =  FFI::AutoPointer.new(LibC.malloc(SIZE), self.class)
  error = LibC.posix_spawnattr_init(@pointer)
  raise SystemCallError.new("posix_spawnattr_init", error) unless error == 0
end

Instance Attribute Details

#pointerObject (readonly)

Returns the value of attribute pointer.



53
54
55
# File 'lib/spoon/unix.rb', line 53

def pointer
  @pointer
end

Class Method Details

.release(ptr) ⇒ Object



62
63
64
65
# File 'lib/spoon/unix.rb', line 62

def self.release(ptr)
  LibC.posix_spawnattr_destroy(ptr)
  LibC.free(ptr)
end

Instance Method Details

#pgroupObject

Raises:

  • (SystemCallError)


73
74
75
76
77
78
# File 'lib/spoon/unix.rb', line 73

def pgroup
  group = FFI::MemoryPointer.new :pid_t
  error = LibC.posix_spawnattr_getpgroup(pointer, group)
  raise SystemCallError.new("posix_spawnattr_getpgroup", error) unless error == 0
  get_pid(group)
end

#pgroup=(group) ⇒ Object

Raises:

  • (SystemCallError)


67
68
69
70
71
# File 'lib/spoon/unix.rb', line 67

def pgroup=(group)
  error = LibC.posix_spawnattr_setpgroup(pointer, group)
  raise SystemCallError.new("posix_spawnattr_setpgroup", error) unless error == 0
  group
end