Permalink
Browse files

proxy window size changes (& SIGWINCH)

  • Loading branch information...
1 parent 0a12d7d commit c45d8c83c9cf52e20a5c543d6cddfb95851753cd @ThomasHabets committed Jan 26, 2009
Showing with 41 additions and 3 deletions.
  1. +1 −1 .be/bugs/9c2b737d-c360-4bac-87f6-679bc9de1c5d/values
  2. +20 −1 client.c
  3. +1 −0 injcode.h
  4. +19 −1 retty.cc
@@ -15,7 +15,7 @@ severity=minor
-status=open
+status=closed
View
@@ -23,12 +23,21 @@ void sigint(int a)
}
+void
+sigwinch(int unused)
+{
+ printf("Sigwinch!\n");
+}
+
int
main()
{
int n = 0, t;
int pid;
+
+ signal(SIGWINCH, sigwinch);
+
if (0) {
doit();
}
@@ -62,7 +71,17 @@ main()
strerror(errno));
}
for(;;) {
- printf("Loop pid=%d %d\n", getpid(), n++);
+ struct winsize w;
+
+ if (-1 == ioctl(0, TIOCGWINSZ, &w)) {
+ fprintf(stderr, "ioctl(TIOCGWINSZ) fail: %s\n",
+ strerror(errno));
+ }
+
+ printf("Loop pid=%d (winsz: %hdx%hd) %d\n",
+ getpid(),
+ w.ws_col, w.ws_row,
+ n++);
//fprintf(stderr, "> lala\n");
if (1) {
sleep(1);
View
@@ -23,6 +23,7 @@ class Retty: public InjMod {
std::string readFd(int fd);
void setRawTerminal(int fd);
void setupPty();
+ static void sigwinch(int);
public:
Retty(Inject&);
void run();
View
@@ -23,6 +23,24 @@ static int proxyfdm, proxyfds;
static pid_t childpid;
static struct termios orig_tio;
+void
+Retty::sigwinch(int unused)
+{
+ struct winsize ws;
+ if (0 > ioctl(0, TIOCGWINSZ, &ws)) {
+ throw ErrHandling::ErrSys("Retty::sigwinch",
+ "ioctl",
+ "TIOCGWINSZ");
+ perror("ioctl(0, TIOCGWINSZ, ...)");
+ }
+ if (0 > ioctl(proxyfdm, TIOCSWINSZ, &ws)) {
+ throw ErrHandling::ErrSys("Retty::sigwinch",
+ "ioctl",
+ "TIOCSWINSZ");
+ perror("ioctl(0, TIOCSWINSZ, ...)");
+ }
+}
+
int
Retty::send_fds(int sd, int proxyfd)
{
@@ -150,14 +168,14 @@ Retty::setupPty()
"openpty",
"");
}
-
childpid = fork();
if (!childpid) {
close(proxyfdm);
child(proxyfds);
exit(0);
}
close(proxyfds);
+ signal(SIGWINCH, sigwinch);
// FIXME: communicate with child so we know when it's ready.
// don't just sleep() arbitrarily.

0 comments on commit c45d8c8

Please sign in to comment.