1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 09:12:24 +00:00

Unix plink now catches SIGWINCH and propagates local terminal

resizes to the remote end.

[originally from svn r2515]
This commit is contained in:
Simon Tatham 2003-01-09 18:28:01 +00:00
parent f928707849
commit 35cd654c75
2 changed files with 32 additions and 2 deletions

2
Recipe
View File

@ -145,7 +145,7 @@ puttygen : [G] puttygen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
pterm : [X] pterm terminal wcwidth uxucs uxmisc tree234 misc ldisc ldiscucs pterm : [X] pterm terminal wcwidth uxucs uxmisc tree234 misc ldisc ldiscucs
+ logging uxprint settings pty be_none uxstore signal CHARSET + logging uxprint settings pty be_none uxstore signal CHARSET
plink : [U] uxplink uxcons NONSSH UXSSH be_all logging UXMISC plink : [U] uxplink uxcons NONSSH UXSSH be_all logging UXMISC signal
PuTTY : [M] terminal wcwidth ldiscucs logging be_all mac macdlg PuTTY : [M] terminal wcwidth ldiscucs logging be_all mac macdlg
+ macterm macucs mac_res.rsrc testback NONSSH MACSSH MACMISC CHARSET + macterm macucs mac_res.rsrc testback NONSSH MACSSH MACMISC CHARSET

View File

@ -4,8 +4,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h>
#include <assert.h> #include <assert.h>
#include <stdarg.h> #include <stdarg.h>
#include <signal.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <termios.h> #include <termios.h>
@ -208,6 +210,13 @@ int from_backend(void *frontend_handle, int is_stderr, char *data, int len)
return osize + esize; return osize + esize;
} }
int signalpipe[2];
void sigwinch(int signum)
{
write(signalpipe[1], "x", 1);
}
/* /*
* Short description of parameters. * Short description of parameters.
*/ */
@ -520,6 +529,15 @@ int main(int argc, char **argv)
if (portnumber != -1) if (portnumber != -1)
cfg.port = portnumber; cfg.port = portnumber;
/*
* Set up the pipe we'll use to tell us about SIGWINCH.
*/
if (pipe(signalpipe) < 0) {
perror("pipe");
exit(1);
}
putty_signal(SIGWINCH, sigwinch);
sk_init(); sk_init();
/* /*
@ -565,6 +583,8 @@ int main(int argc, char **argv)
FD_ZERO(&xset); FD_ZERO(&xset);
maxfd = 0; maxfd = 0;
FD_SET_MAX(signalpipe[0], maxfd, rset);
if (connopen && !sending && if (connopen && !sending &&
back->socket(backhandle) != NULL && back->socket(backhandle) != NULL &&
back->sendok(backhandle) && back->sendok(backhandle) &&
@ -610,7 +630,9 @@ int main(int argc, char **argv)
FD_SET_MAX(socket, maxfd, xset); FD_SET_MAX(socket, maxfd, xset);
} }
do {
ret = select(maxfd, &rset, &wset, &xset, NULL); ret = select(maxfd, &rset, &wset, &xset, NULL);
} while (ret < 0 && errno == EINTR);
if (ret < 0) { if (ret < 0) {
perror("select"); perror("select");
@ -632,6 +654,14 @@ int main(int argc, char **argv)
select_result(socket, 2); select_result(socket, 2);
} }
if (FD_ISSET(signalpipe[0], &rset)) {
char c[1];
struct winsize size;
read(signalpipe[0], c, 1); /* ignore its value; it'll be `x' */
if (ioctl(0, TIOCGWINSZ, (void *)&size) >= 0)
back->size(backhandle, size.ws_col, size.ws_row);
}
if (FD_ISSET(0, &rset)) { if (FD_ISSET(0, &rset)) {
char buf[4096]; char buf[4096];
int ret; int ret;