From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1501 invoked from network); 18 May 1997 09:39:14 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 18 May 1997 09:39:14 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id FAA14533; Sun, 18 May 1997 05:27:48 -0400 (EDT) Resent-Date: Sun, 18 May 1997 05:27:48 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199705180930.FAA05454@hzoli.home> Subject: More LINES/COLUMNS changes To: zsh-workers@math.gatech.edu (Zsh hacking and development) Date: Sun, 18 May 1997 05:30:30 -0400 (EDT) X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"roY5k1.0.0Z3.KkiVp"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3156 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Zsh-3.1.2-test1 and zsh-3.0.3-test5 still does not set LINES correctly on startup for non-interractive shells. Non-interactive shells did not trap SIGWINCH by default. This patch removes window size check from gettyinfo, traps SIGWINCH for all shells not just for interactive shells, and calls adjustwinsize() in update_job() only if MONITOR is set and the shell was detached from the terminal during the execution of a foreground process. gettyinfo is called from update_job() if shout was initialised regardles of the process groups or the exit value of the job. It seems that before this patch shttyinfo was not updated if a process exited with nonzero exit status. Anyone knows the reason for that? The #if defined(__sgi) part from init_shout should probably go to gettyinfo(), but I do not what it does, so I did not move it. This patch applies to unchanged zsh-3.1.2-test1 or zsh-3.0.3-test5. If you applied my previous patch to jobs.c, remove it before applying this patch. Zoltan *** Src/init.c 1997/05/11 05:01:43 3.1.2.10 --- Src/init.c 1997/05/18 08:06:41 *************** *** 519,526 **** createparamtable(); /* create paramater hash table */ #ifdef TIOCGWINSZ ! setiparam("COLUMNS", shttyinfo.winsize.ws_col); ! setiparam("LINES", shttyinfo.winsize.ws_row); #else /* Using zero below sets the defaults from termcap */ setiparam("COLUMNS", 0); --- 519,525 ---- createparamtable(); /* create paramater hash table */ #ifdef TIOCGWINSZ ! adjustwinsize(); #else /* Using zero below sets the defaults from termcap */ setiparam("COLUMNS", 0); *************** *** 571,581 **** install_handler(SIGHUP); install_handler(SIGCHLD); - if (interact) { - install_handler(SIGALRM); #ifdef SIGWINCH ! install_handler(SIGWINCH); #endif signal_ignore(SIGTERM); } if (jobbing) { --- 570,580 ---- install_handler(SIGHUP); install_handler(SIGCHLD); #ifdef SIGWINCH ! install_handler(SIGWINCH); #endif + if (interact) { + install_handler(SIGALRM); signal_ignore(SIGTERM); } if (jobbing) { *************** *** 685,691 **** if (interact && isset(RCS)) readhistfile(getsparam("HISTFILE"), 0); - adjustwinsize(); /* check window size and adjust if necessary */ } /* source a file */ --- 684,689 ---- *** Src/utils.c 1997/05/09 07:59:00 3.1.2.12 --- Src/utils.c 1997/05/18 07:53:10 *************** *** 752,762 **** ioctl(SHTTY, TIOCGLTC, &ti->ltchars); # endif #endif - #ifdef TIOCGWINSZ - /* if (ioctl(SHTTY, TIOCGWINSZ, &ti->winsize) == -1) - zerr("bad tiocgwinsz: %e",NULL,errno);*/ - ioctl(SHTTY, TIOCGWINSZ, (char *)&ti->winsize); - #endif } } --- 752,757 ---- *** Src/jobs.c 1997/05/09 04:55:51 3.1.2.3 --- Src/jobs.c 1997/05/18 08:37:32 *************** *** 120,126 **** int job; int val = 0, status = 0; int somestopped = 0, inforeground = 0; - pid_t pgrp; for (pn = jn->procs; pn; pn = pn->next) { if (pn->status == SP_RUNNING) /* some processes in this job are running */ --- 120,125 ---- *************** *** 154,166 **** } } ! pgrp = gettygrp(); /* get process group of tty */ ! ! /* is this job in the foreground of an interactive shell? */ ! if ((jn->gleader == pgrp || (pgrp > 1 && kill(-pgrp, 0) == -1)) && ! !ttyfrozen && !val && !jn->stty_in_env) gettyinfo(&shttyinfo); ! adjustwinsize(); /* check window size and adjust if necessary */ if (somestopped && jn->stat & STAT_SUPERJOB) return; jn->stat |= (somestopped) ? STAT_CHANGED | STAT_STOPPED : --- 153,172 ---- } } ! if (shout && !ttyfrozen && !jn->stty_in_env) gettyinfo(&shttyinfo); ! ! if (isset(MONITOR)) { ! pid_t pgrp = gettygrp(); /* get process group of tty */ ! ! /* is this job in the foreground of an interactive shell? */ ! if (mypgrp != pgrp && (jn->gleader == pgrp || ! (pgrp > 1 && kill(-pgrp, 0) == -1))) { ! attachtty(mypgrp); ! adjustwinsize(); /* check window size and adjust if necessary */ ! } ! } ! if (somestopped && jn->stat & STAT_SUPERJOB) return; jn->stat |= (somestopped) ? STAT_CHANGED | STAT_STOPPED :