Merge branch '61432-lib-tasks-lint-rake-can-block-indefinitely-if-stderr-fills-up' into 'master'

Resolve "lib/tasks/lint.rake can block indefinitely if stderr fills up"

Closes #61432

See merge request gitlab-org/gitlab-ce!28402
This commit is contained in:
Stan Hu 2019-05-18 15:02:38 +00:00
commit a14572593e

View file

@ -37,32 +37,15 @@ unless Rails.env.production?
lint:static_verification
].each do |task|
pid = Process.fork do
rd_out, wr_out = IO.pipe
rd_err, wr_err = IO.pipe
stdout = $stdout.dup
stderr = $stderr.dup
$stdout.reopen(wr_out)
$stderr.reopen(wr_err)
puts "*** Running rake task: #{task} ***"
begin
Rake::Task[task].invoke
rescue SystemExit => ex
msg = "*** Rake task #{task} exited:"
raise ex
rescue => ex
msg = "*** Rake task #{task} raised #{ex.class}:"
raise ex
ensure
$stdout.reopen(stdout)
$stderr.reopen(stderr)
wr_out.close
wr_err.close
warn "\n#{msg}\n\n" if msg
IO.copy_stream(rd_out, $stdout)
IO.copy_stream(rd_err, $stderr)
end
Rake::Task[task].invoke
rescue SystemExit => ex
warn "!!! Rake task #{task} exited:"
raise ex
rescue StandardError, ScriptError => ex
warn "!!! Rake task #{task} raised #{ex.class}:"
raise ex
end
Process.waitpid(pid)