Class: Spoon::SpawnAttributes

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

Defined Under Namespace

Classes: Releaser

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpawnAttributes

Returns a new instance of SpawnAttributes.

Raises:

  • (SystemCallError)


58
59
60
61
62
# File 'lib/spoon/unix.rb', line 58

def initialize
  @pointer =  FFI::AutoPointer.new(LibC.malloc(SIZE), Releaser)
  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.



55
56
57
# File 'lib/spoon/unix.rb', line 55

def pointer
  @pointer
end

Instance Method Details

#pgroupObject

Raises:

  • (SystemCallError)


77
78
79
80
81
82
# File 'lib/spoon/unix.rb', line 77

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)


71
72
73
74
75
# File 'lib/spoon/unix.rb', line 71

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