spoon 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/spoon/unix.rb +13 -9
- data/spoon.gemspec +1 -1
- metadata +1 -1
data/lib/spoon/unix.rb
CHANGED
@@ -20,14 +20,16 @@ module Spoon
|
|
20
20
|
SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 128
|
21
21
|
|
22
22
|
def initialize
|
23
|
-
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE),
|
23
|
+
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), Releaser)
|
24
24
|
error = LibC.posix_spawn_file_actions_init(@pointer)
|
25
25
|
raise SystemCallError.new("posix_file_actions_init", error) unless error == 0
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
class Releaser
|
29
|
+
def self.call(ptr)
|
30
|
+
LibC.posix_spawn_file_actions_destroy(ptr)
|
31
|
+
LibC.free(ptr)
|
32
|
+
end
|
31
33
|
end
|
32
34
|
|
33
35
|
def open(fd, path, oflag, mode)
|
@@ -51,17 +53,19 @@ module Spoon
|
|
51
53
|
|
52
54
|
class SpawnAttributes
|
53
55
|
attr_reader :pointer
|
54
|
-
SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) :
|
56
|
+
SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 512
|
55
57
|
|
56
58
|
def initialize
|
57
|
-
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE),
|
59
|
+
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), Releaser)
|
58
60
|
error = LibC.posix_spawnattr_init(@pointer)
|
59
61
|
raise SystemCallError.new("posix_spawnattr_init", error) unless error == 0
|
60
62
|
end
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
class Releaser
|
65
|
+
def self.call(ptr)
|
66
|
+
LibC.posix_spawnattr_destroy(ptr)
|
67
|
+
LibC.free(ptr)
|
68
|
+
end
|
65
69
|
end
|
66
70
|
|
67
71
|
def pgroup=(group)
|
data/spoon.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "spoon"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.4"
|
4
4
|
s.authors = ["Charles Oliver Nutter"]
|
5
5
|
s.date = "2013-03-29"
|
6
6
|
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."
|