Pass correct window size to underlying application

This commit is contained in:
Marc André Tanner 2014-06-19 10:30:03 +02:00
parent 5a88eee291
commit 76bbea220b
1 changed files with 7 additions and 1 deletions

View File

@ -100,6 +100,7 @@ typedef struct {
int pty;
int exit_status;
struct termios term;
struct winsize winsize;
pid_t pid;
volatile sig_atomic_t running;
const char *name;
@ -269,7 +270,7 @@ static bool create_session(const char *name, char * const argv[]) {
sigemptyset(&sa.sa_mask);
sa.sa_handler = server_pty_died_handler;
sigaction(SIGCHLD, &sa, NULL);
switch (server.pid = forkpty(&server.pty, NULL, has_term ? &server.term : NULL, NULL)) {
switch (server.pid = forkpty(&server.pty, NULL, has_term ? &server.term : NULL, &server.winsize)) {
case 0: /* child process */
fcntl(pipefds[1], F_SETFD, FD_CLOEXEC);
close(server.socket);
@ -471,6 +472,11 @@ int main(int argc, char *argv[]) {
has_term = true;
}
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &server.winsize) == -1) {
server.winsize.ws_col = 80;
server.winsize.ws_row = 25;
}
server.read_pty = (action == 'n');
switch (action) {