Skip to content

Shutdown hijacked stdin#1567

Open
bsideup wants to merge 2 commits intomainfrom
close_hijacked_stdin
Open

Shutdown hijacked stdin#1567
bsideup wants to merge 2 commits intomainfrom
close_hijacked_stdin

Conversation

@bsideup
Copy link
Copy Markdown
Member

@bsideup bsideup commented Mar 26, 2021

Fixes #1448


This change is Reviewable

@bsideup
Copy link
Copy Markdown
Member Author

bsideup commented Mar 29, 2021

It looks like there are two challenges with this:

  1. OkHttp + TCP transport does not pass
  2. Npipe does not implement shutdownOutput properly

putting on hold for now

@luneo7
Copy link
Copy Markdown

luneo7 commented May 13, 2022

Tested you branch and just changing com.github.dockerjava.okhttp.HijackingInterceptor thread to something like

Thread thread = new Thread(() -> {
    try {
        try (BufferedSink sink = streams.sink) {
            while (sink.isOpen()) {
                int aByte = stdin.read();
                if (aByte < 0) {
                    break;
                }
                sink.writeByte(aByte);
                sink.emit();
            }
        }
        Connection connection = chain.connection();
        if (connection != null) {
            connection.socket().shutdownOutput();
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
});

Makes it work with Okhttp3 =]

@eddumelendez eddumelendez requested a review from a team as a code owner August 19, 2025 18:23
@mikehearn
Copy link
Copy Markdown

Just hit this! Even just fixing it for some backends would be great. BTW the zerodeps backend has the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdin remains open in Docker container after closing it on docker-java side via OkHttp

3 participants