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

Running exec locks the terminal #73

Open
anlek opened this issue Feb 22, 2022 · 2 comments
Open

Running exec locks the terminal #73

anlek opened this issue Feb 22, 2022 · 2 comments

Comments

@anlek
Copy link

anlek commented Feb 22, 2022

I'm trying to build a CLI helper app, and when I try to execute session.run!('exec', service, command) (and the service is running), it loads the correct container, it shows me the bash terminal, however, all my inputs are locked up... I can't even ctrl+c to exit it.

Any idea why?

@anlek
Copy link
Author

anlek commented Feb 22, 2022

Hmm, it seems that me setting IO.console.raw! (or STDOUT.raw!) it break the input :(
However, if I don't do it, it still seems that it doesn't work with OUTPUT.
Example: I can call ls and when I hit return, it doesn't give any feedback. I can send ctrl-c and it will exit the execution though.

@xeger
Copy link
Owner

xeger commented Apr 1, 2022

It's hard to know precisely what is wrong without having a reproduction to play with. However, I think the core issue is due to the backticks gem, which docker-compose uses to interact with the Compose subprocess.

Backticks has some powerful features (pseudo TTY, interactivity, etc) but if your exec is creating an interactive container, then that container is tied to your terminal. If that container prompts you for input, then it may hang the compose gem.

If you check Docker::Compose::Session you will see it has an initializer param:

def initialize (shell = Backticks::Runner.new(buffered: [:stderr], interactive: true)

You can pass your own shell and initialize the backticks runner differently. I would try passing an interactive: false runner and also buffered: [] to see if that fixes things or reveals more output.

If you can point me toward a public reproduction, I will have a closer look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants