Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell command stalls if command produces lots of output #507

Closed
youngm opened this issue Oct 26, 2017 · 0 comments
Closed

shell command stalls if command produces lots of output #507

youngm opened this issue Oct 26, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@youngm
Copy link
Contributor

youngm commented Oct 26, 2017

https://github.com/cloudfoundry/java-buildpack/blob/master/lib/java_buildpack/util/shell.rb

In a buildpack customization, I execute a shell command that produces a lot of stdout/stderr. When I do the buildpack staging stalls. It appears this is happening because the thread will stall if it cannot write all output to stdout and stderr.

This doesn't appear to affect other buildpack commands because the stdout/stderr buffers are large enough to hold all their command output.

Changing the implementation to the following worked around my problem:

        Open3.popen3(*args) do |_stdin, stdout, stderr, wait_thr|
          stdout = stdout.gets nil
          stderr = stderr.gets nil
          unless wait_thr.value.success?
            puts "\nCommand '#{args.join ' '}' has failed"
            puts "STDOUT: #{stdout}"
            puts "STDERR: #{stderr}"

            raise
          end
        end
@nebhale nebhale self-assigned this Oct 27, 2017
@nebhale nebhale added the bug label Oct 27, 2017
@nebhale nebhale added this to the v4.7 milestone Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants