Commit b316df46 authored by Cédric Boutillier's avatar Cédric Boutillier

Imported Upstream version 0.0.4

parent eae43000
...@@ -20,14 +20,16 @@ module Spoon ...@@ -20,14 +20,16 @@ module Spoon
SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 128 SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 128
def initialize def initialize
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), self.class) @pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), Releaser)
error = LibC.posix_spawn_file_actions_init(@pointer) error = LibC.posix_spawn_file_actions_init(@pointer)
raise SystemCallError.new("posix_file_actions_init", error) unless error == 0 raise SystemCallError.new("posix_file_actions_init", error) unless error == 0
end end
def self.release(ptr) class Releaser
LibC.posix_spawn_file_actions_destroy(ptr) def self.call(ptr)
LibC.free(ptr) LibC.posix_spawn_file_actions_destroy(ptr)
LibC.free(ptr)
end
end end
def open(fd, path, oflag, mode) def open(fd, path, oflag, mode)
...@@ -51,17 +53,19 @@ module Spoon ...@@ -51,17 +53,19 @@ module Spoon
class SpawnAttributes class SpawnAttributes
attr_reader :pointer attr_reader :pointer
SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 128 SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 512
def initialize def initialize
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), self.class) @pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), Releaser)
error = LibC.posix_spawnattr_init(@pointer) error = LibC.posix_spawnattr_init(@pointer)
raise SystemCallError.new("posix_spawnattr_init", error) unless error == 0 raise SystemCallError.new("posix_spawnattr_init", error) unless error == 0
end end
def self.release(ptr) class Releaser
LibC.posix_spawnattr_destroy(ptr) def self.call(ptr)
LibC.free(ptr) LibC.posix_spawnattr_destroy(ptr)
LibC.free(ptr)
end
end end
def pgroup=(group) def pgroup=(group)
......
--- !ruby/object:Gem::Specification --- !ruby/object:Gem::Specification
name: spoon name: spoon
version: !ruby/object:Gem::Version version: !ruby/object:Gem::Version
version: 0.0.3
prerelease: prerelease:
version: 0.0.4
platform: ruby platform: ruby
authors: authors:
- Charles Oliver Nutter - Charles Oliver Nutter
......
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "spoon" s.name = "spoon"
s.version = "0.0.3" s.version = "0.0.4"
s.authors = ["Charles Oliver Nutter"] s.authors = ["Charles Oliver Nutter"]
s.date = "2013-03-29" s.date = "2013-03-29"
s.description = s.summary = "Spoon is an FFI binding of the posix_spawn function (and Windows equivalent), providing fork+exec functionality in a single shot." s.description = s.summary = "Spoon is an FFI binding of the posix_spawn function (and Windows equivalent), providing fork+exec functionality in a single shot."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment