attempt to save terminal history with EOF #7769
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Apr 26, 2026 at 10:56 UTC
e238f58b2d1af3697dafea9a265496210c5d9ff7
1 file changed
+5
agents/meshcore.js
+5
@@ -3983,6 +3983,11 @@ function onTunnelControlData(data, ws) {
3983
case 'close': {
3984
// We received the close on the websocket
3985
//sendConsoleText('Tunnel #' + ws.tunnel.index + ' WebSocket control close');
3986
+ // Attempt to send EOF (Ctrl-D) multiple times to exit nested shells (screen, su, etc.) cleanly,
3987
+ // This allows the shell to write its history before the process is killed
3988
+ if (process.platform != 'win32' && ws.httprequest && ws.httprequest.process && ws.httprequest.process.stdin) {
3989
+ try { ws.httprequest.process.stdin.write('\x04\x04\x04'); } catch (ex) { }
3990
+ }
3991
try { ws.close(); } catch (ex) { }
3992
break;
3993
}