ref: bc54898807d27e79ba9f1b595ef3e09e3da67522
parent: faae8eb752fc9df65811ffb1b8cb8f0594cd4b2f
author: cinap_lenrek <[email protected]>
date: Sun Aug 20 15:17:46 EDT 2017
ssh: issue "winchon" ctl request to /dev/consctl to get interrupt on window size change from vt(1)
--- a/sys/src/cmd/ssh.c
+++ b/sys/src/cmd/ssh.c
@@ -97,7 +97,7 @@
void
catch(void*, char *msg)
{
- if(strstr(msg, "interrupt") != nil){
+ if(strcmp(msg, "interrupt") == 0){
intr = 1;
noted(NCONT);
}
@@ -114,7 +114,7 @@
return 1;
memset(err, 0, sizeof(err));
errstr(err, sizeof(err));
- r = strstr(err, "interrupt") != nil;
+ r = strcmp(err, "interrupted") == 0;
errstr(err, sizeof(err));
return r;
}
@@ -1073,20 +1073,10 @@
} tty;
void
-rawon(void)
+getdim(void)
{
- int ctl;
char *s;
- close(0);
- if(open("/dev/cons", OREAD) != 0)
- sysfatal("open: %r");
- close(1);
- if(open("/dev/cons", OWRITE) != 1)
- sysfatal("open: %r");
- dup(1, 2);
- if((ctl = open("/dev/consctl", OWRITE)) >= 0)
- write(ctl, "rawon", 5);
if(s = getenv("XPIXELS")){
tty.xpixels = atoi(s);
free(s);
@@ -1105,6 +1095,25 @@
}
}
+void
+rawon(void)
+{
+ int ctl;
+
+ close(0);
+ if(open("/dev/cons", OREAD) != 0)
+ sysfatal("open: %r");
+ close(1);
+ if(open("/dev/cons", OWRITE) != 1)
+ sysfatal("open: %r");
+ dup(1, 2);
+ if((ctl = open("/dev/consctl", OWRITE)) >= 0){
+ write(ctl, "rawon", 5);
+ write(ctl, "winchon", 7); /* vt(1): interrupt note on window change */
+ }
+ getdim();
+}
+
#pragma varargck type "k" char*
kfmt(Fmt *f)
@@ -1323,12 +1332,23 @@
break;
if(n < 0 && wasintr()){
if(!raw) break;
- sendpkt("busbs", MSG_CHANNEL_REQUEST,
- send.chan,
- "signal", 6,
- 0,
- "INT", 3);
- intr = 0;
+ if(intr){
+ getdim();
+ sendpkt("busbuuuu", MSG_CHANNEL_REQUEST,
+ send.chan,
+ "window-change", 13,
+ 0,
+ tty.cols,
+ tty.lines,
+ tty.xpixels,
+ tty.ypixels);
+ sendpkt("busbs", MSG_CHANNEL_REQUEST,
+ send.chan,
+ "signal", 6,
+ 0,
+ "INT", 3);
+ intr = 0;
+ }
continue;
}
if(n <= 0)