control-c causes yori prompt to come back while background interactive session still running
My scenario is using the aws cli and session manager to login to a remote host.
I use: >aws ssm start-session --target i-
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!
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.