Skip to content

Commit

Permalink
Test workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed May 14, 2024
1 parent 0c6851b commit ebc6aec
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions lib/sass/compiler/open3.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
# frozen_string_literal: true

module Open3
alias_method :__popen_run, :popen_run

def popen_run(cmd, opts, child_io, parent_io)
pid = spawn(*cmd, opts)
require 'fcntl'

begin
require 'fcntl'

child_io.each do |io|
flags = io.fcntl(Fcntl::F_GETFL)
io.fcntl(Fcntl::F_SETFL, flags | (Fcntl::O_NONBLOCK))
io.fcntl(Fcntl::F_SETFL, flags & (~Fcntl::O_NONBLOCK))
end
rescue
end

wait_thr = Process.detach(pid)
child_io.each(&:close)
result = [*parent_io, wait_thr]
if defined? yield
begin
return yield(*result)
ensure
parent_io.each(&:close)
wait_thr.join
end
module Open3
_popen_run = instance_method(:popen_run)
define_method(:popen_run) do |cmd, opts, child_io, parent_io, &block|
child_io.each do |io|
flags = io.fcntl(Fcntl::F_GETFL)
io.fcntl(Fcntl::F_SETFL, flags | (Fcntl::O_NONBLOCK))
io.fcntl(Fcntl::F_SETFL, flags & (~Fcntl::O_NONBLOCK))
end
result
_popen_run.bind(self).call(cmd, opts, child_io, parent_io, &block)
end
module_function :popen_run
class << self
private :popen_run
end
end

0 comments on commit ebc6aec

Please sign in to comment.