aws / amazon-ssm-agent

An agent to enable remote management of your EC2 instances, on-premises servers, or virtual machines (VMs).
https://aws.amazon.com/systems-manager/
Apache License 2.0
1.06k stars 326 forks source link

`^C` should not unconditionally terminate the session. #483

Open sudoforge opened 2 years ago

sudoforge commented 2 years ago

Instead of sending SIGINT to the shell and terminating the current process (and providing a new prompt), ^C unconditionally terminates the SSM session, even if su - <user> has been used, or if a process is in the foreground tail -f /path/to/file), or from within a nested shell. This behavior is unique to SSM sessions, so I imagine the agent is listening for SIGINT and terminating.... which is fairly cumbersome.

Starting session with SessionId: REDACTED
exec bash
sh-4.2$ exec bash
[ssm-user@ip-123 bin]$ stty -a
speed 38400 baud; rows 61; columns 240; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
[ssm-user@ip-123 bin]$ stty intr \^C
[ssm-user@ip-123 bin]$ ^C
[ssm-user@ip-123 bin]$

$ # now i'm back in my local prompt