From: simon Date: Thu, 9 Jan 2003 18:28:01 +0000 (+0000) Subject: Unix plink now catches SIGWINCH and propagates local terminal X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/commitdiff_plain/5673d44e32142b68913620424c9dc29d66e58c2e Unix plink now catches SIGWINCH and propagates local terminal resizes to the remote end. git-svn-id: svn://svn.tartarus.org/sgt/putty@2515 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/Recipe b/Recipe index 3569fbeb..e3443c0d 100644 --- a/Recipe +++ b/Recipe @@ -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 + 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 + macterm macucs mac_res.rsrc testback NONSSH MACSSH MACMISC CHARSET diff --git a/unix/uxplink.c b/unix/uxplink.c index a005ce6d..96d3f189 100644 --- a/unix/uxplink.c +++ b/unix/uxplink.c @@ -4,8 +4,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -208,6 +210,13 @@ int from_backend(void *frontend_handle, int is_stderr, char *data, int len) return osize + esize; } +int signalpipe[2]; + +void sigwinch(int signum) +{ + write(signalpipe[1], "x", 1); +} + /* * Short description of parameters. */ @@ -520,6 +529,15 @@ int main(int argc, char **argv) if (portnumber != -1) 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(); /* @@ -565,6 +583,8 @@ int main(int argc, char **argv) FD_ZERO(&xset); maxfd = 0; + FD_SET_MAX(signalpipe[0], maxfd, rset); + if (connopen && !sending && back->socket(backhandle) != NULL && back->sendok(backhandle) && @@ -610,7 +630,9 @@ int main(int argc, char **argv) FD_SET_MAX(socket, maxfd, xset); } - ret = select(maxfd, &rset, &wset, &xset, NULL); + do { + ret = select(maxfd, &rset, &wset, &xset, NULL); + } while (ret < 0 && errno == EINTR); if (ret < 0) { perror("select"); @@ -632,6 +654,14 @@ int main(int argc, char **argv) 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)) { char buf[4096]; int ret;