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

control-c causes yori prompt to come back while background interactive session still running #37

Open
mattgillard opened this issue Apr 22, 2020 · 1 comment
Labels
external The ideal change is in another component

Comments

@mattgillard
Copy link

My scenario is using the aws cli and session manager to login to a remote host.
I use: >aws ssm start-session --target i-
Everything works fine until i hit control-c - then the yori prompt comes back interleaved with my remote session even though my aws session is still active:

ssm-user@ip-10-0-3-189:/var/snap/amazon-ssm-agent/1565$
C:\Users\matt\OneDrive\Documents\dev>
ssm-user@ip-10-0-3-189:/var/snap/amazon-ssm-agent/1565$
C:\Users\matt\OneDrive\Documents\dev>

Situation is unusable until i go into a second session and kill my first one with aws ssm terminate-session. Then i can re-connect fine. Its like yori took control of my control-c and thought i wanted to terminate the aws ssm process but it doesnt realise it is an interactive session?

Using ssh is fine - control-c works as expected.
aws ssm start-session works as expected in a cmd.exe session.

thanks!

@malxau
Copy link
Owner

malxau commented Apr 25, 2020

I looked into this a bit, but it looks like the aws cli went out of its way to make this happen. See:

https://github.com/aws/aws-cli/blob/e87b769bd717b895e00fd48a3b5592db825402ef/awscli/compat.py#L332

This is used when creating sessions specifically to prevent the child from receiving the Ctrl+C signal. Yori, and CMD, both launch child processes in a mode where the Ctrl+C is sent to those processes and they terminate themselves. The aws cli is suppressing receipt of the message.

One difference between Yori and CMD is that Yori will wait 50ms for the child process to die, and if it doesn't it is killed forcibly with TerminateProcess. That means if Yori launches one process, and that process launches another process, it is willing to kill the immediate child and leave its child running, which is probably what happened here. My knee-jerk reaction to this is to use job objects to kill all processes - but note that doing so is doing the exact opposite of what the aws cli is trying to achieve.

@malxau malxau added the external The ideal change is in another component label May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external The ideal change is in another component
Projects
None yet
Development

No branches or pull requests

2 participants