binaryen 1.1.6.5 → 1.1.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/binaryen/command.rb +17 -19
- data/lib/binaryen/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44bf5b373ce186bdee3006d16e8129bde2be3e952c1211d3ee550fb529cffbfe
|
4
|
+
data.tar.gz: c3ef7a60460cdc937e51b538ef4e6d94ebfba2167ff14821292881a9b91d6f1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 290897e4df9079e57df51b4b684fa5ae496ea414c44d801ed8d2be5c167d5347812533511ee26b8f59520d645df1072df5c6368d218ab824d89b38e07373e7b5
|
7
|
+
data.tar.gz: c30ed5adcb899a8d938d211b3aa3e98e875ec061f19054efd5d7a803b9be0392f9215cbac61283147841e23171ead48391f06695aa06841a64a6be05d5ba57aa
|
data/lib/binaryen/command.rb
CHANGED
@@ -30,7 +30,7 @@ module Binaryen
|
|
30
30
|
def check!
|
31
31
|
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
32
32
|
if now >= @end_time
|
33
|
-
Process.kill("
|
33
|
+
Process.kill("TERM", @pid)
|
34
34
|
raise Timeout::Error, "Command timed out"
|
35
35
|
end
|
36
36
|
remaining_time = @end_time - now
|
@@ -50,47 +50,45 @@ module Binaryen
|
|
50
50
|
pid, iwr, ord, erd = popen4(*command)
|
51
51
|
timeout_checker = TimeoutChecker.new(end_time: end_time, pid: pid)
|
52
52
|
|
53
|
-
write_to_pipe(iwr, stdin, timeout_checker) if stdin
|
53
|
+
write_to_pipe(iwr, stdin, timeout_checker, pid) if stdin
|
54
|
+
|
54
55
|
if stderr
|
55
56
|
err_output = read_from_pipe(erd, timeout_checker)
|
56
|
-
|
57
|
-
write_to_pipe(stderr, err_output, timeout_checker, close_write: false)
|
58
|
-
rescue Errno::EPIPE
|
59
|
-
# ignore
|
60
|
-
end
|
57
|
+
write_to_pipe(stderr, err_output, timeout_checker, pid, close_write: false)
|
61
58
|
end
|
62
59
|
output = read_from_pipe(ord, timeout_checker)
|
63
|
-
wait_or_kill(pid, timeout_checker
|
60
|
+
wait_or_kill(pid, timeout_checker)
|
64
61
|
|
65
62
|
output
|
66
63
|
end
|
67
64
|
|
68
65
|
private
|
69
66
|
|
70
|
-
def write_to_pipe(pipe, stdin, timeout_checker, close_write: true)
|
67
|
+
def write_to_pipe(pipe, stdin, timeout_checker, pid, close_write: true)
|
71
68
|
offset = 0
|
72
69
|
length = stdin.bytesize
|
73
70
|
|
74
71
|
while offset < length
|
75
72
|
remaining_time = timeout_checker.check!
|
76
73
|
|
77
|
-
|
74
|
+
next unless IO.select(nil, [pipe], nil, remaining_time)
|
75
|
+
|
76
|
+
begin
|
78
77
|
written = pipe.write_nonblock(stdin.byteslice(offset, length), exception: false)
|
79
78
|
offset += written if written.is_a?(Integer)
|
80
|
-
|
81
|
-
|
79
|
+
rescue Errno::EPIPE
|
80
|
+
wait_or_kill(pid, timeout_checker, pid)
|
82
81
|
end
|
83
82
|
end
|
84
|
-
|
83
|
+
ensure
|
85
84
|
pipe.close_write if close_write
|
86
85
|
end
|
87
86
|
|
88
|
-
def read_from_pipe(pipe, timeout_checker)
|
87
|
+
def read_from_pipe(pipe, timeout_checker, close_read: true)
|
89
88
|
output = +""
|
90
89
|
|
91
90
|
while (result = pipe.read_nonblock(8192, exception: false))
|
92
91
|
remaining_time = timeout_checker.check!
|
93
|
-
raise Timeout::Error, "Command timed out" if remaining_time <= 0
|
94
92
|
|
95
93
|
case result
|
96
94
|
when :wait_readable
|
@@ -103,15 +101,15 @@ module Binaryen
|
|
103
101
|
end
|
104
102
|
|
105
103
|
output
|
104
|
+
ensure
|
105
|
+
pipe.close_read if close_read
|
106
106
|
end
|
107
107
|
|
108
|
-
def wait_or_kill(pid, timeout_checker
|
108
|
+
def wait_or_kill(pid, timeout_checker)
|
109
109
|
loop do
|
110
|
-
|
111
|
-
raise Timeout::Error, "timed out waiting on process" if remaining_time <= 0
|
110
|
+
timeout_checker.check!
|
112
111
|
|
113
112
|
if (_, status = Process.wait2(pid, Process::WNOHANG))
|
114
|
-
|
115
113
|
raise Binaryen::NonZeroExitStatus,
|
116
114
|
"command exited with status #{status.exitstatus}" if status.exitstatus != 0
|
117
115
|
|
data/lib/binaryen/version.rb
CHANGED