From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mike Kupfer Newsgroups: gmane.emacs.devel Subject: Re: misbehavior in shell window with ksh Date: Thu, 04 May 2017 20:04:03 -0700 Message-ID: <914.1493953443@alto> References: <8337ckhedo.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1493953465 1213 195.159.176.226 (5 May 2017 03:04:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 5 May 2017 03:04:25 +0000 (UTC) Cc: Stephen Berman , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 05 05:04:22 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d6TXZ-0000ES-NV for ged-emacs-devel@m.gmane.org; Fri, 05 May 2017 05:04:21 +0200 Original-Received: from localhost ([::1]:44751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6TXf-00032T-EU for ged-emacs-devel@m.gmane.org; Thu, 04 May 2017 23:04:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6TXU-00031B-0q for emacs-devel@gnu.org; Thu, 04 May 2017 23:04:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6TXQ-00088w-2H for emacs-devel@gnu.org; Thu, 04 May 2017 23:04:16 -0400 Original-Received: from shell1.rawbw.com ([198.144.192.42]:49821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6TXP-00088K-Ox; Thu, 04 May 2017 23:04:11 -0400 Original-Received: from alto (m208-249.dsl.rawbw.com [198.144.208.249]) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTP id v45344Xa002794; Thu, 4 May 2017 20:04:04 -0700 (PDT) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host m208-249.dsl.rawbw.com [198.144.208.249] claimed to be alto In-Reply-To: Your message of "Thu, 04 May 2017 17:42:59 +0300." <8337ckhedo.fsf@gnu.org> X-Mailer: MH-E 8.6+git; nmh 1.6; GNU Emacs 26.0.50 Content-ID: <913.1493953443.1@alto> X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 198.144.192.42 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214572 Archived-At: Eli Zaretskii wrote: > Can the shell experts among us please tell whether this is an expected > reaction of a shell to window-resizing ioctl? And why this is only > seen with ksh? And why in some cases one needs to set EDITOR in the > environment? I'm not a shell expert, but I did spend a little time with strace to see what ksh is doing. In a regular terminal emulator (xfce4-terminal), when ksh gets SIGWINCH, it queries for the size of the screen, and it generates one or more carriage returns before (re)writing the PS1 prompt. --- SIGWINCH {si_signo=3DSIGWINCH, si_code=3DSI_KERNEL} --- rt_sigaction(SIGWINCH, {0x41c250, [], SA_RESTORER|SA_INTERRUPT, 0x7f91cb= 7cd0e0}, {0x41c250, [], SA_RESTORER|SA_INTERRUPT, 0x7f91cb7cd0e0}, 8) =3D = 0 ioctl(2, TIOCGWINSZ, {ws_row=3D25, ws_col=3D80, ws_xpixel=3D0, ws_ypixel= =3D0}) =3D 0 rt_sigprocmask(SIG_UNBLOCK, [WINCH], NULL, 8) =3D 0 rt_sigreturn() =3D -1 EINTR (Interrupted system= call) write(2, "\r", 1) =3D 1 ioctl(2, TIOCGWINSZ, {ws_row=3D25, ws_col=3D80, ws_xpixel=3D0, ws_ypixel= =3D0}) =3D 0 poll(0x7ffcc1e41dc0, 0, 50) =3D 0 (Timeout) ioctl(2, TIOCGWINSZ, {ws_row=3D25, ws_col=3D80, ws_xpixel=3D0, ws_ypixel= =3D0}) =3D 0 write(2, "\ralto$ ", 7) =3D 7 select(1, [0], NULL, NULL, NULL) =3D ? ERESTARTNOHAND (To be rest= arted if no handler) Its behavior in a shell buffer is similar, except it just writes out the PS2 prompt. --- SIGWINCH {si_signo=3DSIGWINCH, si_code=3DSI_KERNEL} --- rt_sigaction(SIGWINCH, {0x41c250, [], SA_RESTORER|SA_INTERRUPT, 0x7fc028= 02d0e0}, {0x41c250, [], SA_RESTORER|SA_INTERRUPT, 0x7fc02802d0e0}, 8) =3D = 0 ioctl(2, TIOCGWINSZ, {ws_row=3D32, ws_col=3D78, ws_xpixel=3D0, ws_ypixel= =3D0}) =3D 0 rt_sigprocmask(SIG_UNBLOCK, [WINCH], NULL, 8) =3D 0 rt_sigreturn() =3D -1 EINTR (Interrupted system= call) ioctl(2, TIOCGWINSZ, {ws_row=3D32, ws_col=3D78, ws_xpixel=3D0, ws_ypixel= =3D0}) =3D 0 poll(0x7ffc9eb5abf0, 0, 50) =3D 0 (Timeout) ioctl(2, TIOCGWINSZ, {ws_row=3D32, ws_col=3D78, ws_xpixel=3D0, ws_ypixel= =3D0}) =3D 0 select(1, [0], NULL, NULL, {0, 0}) =3D 0 (Timeout) write(2, "> ", 2) =3D 2 I can't explain the difference. I also checked bash's behavior. It does not query the current screen size. bash in an Emacs shell buffer: read(0, 0x6fdc00, 128) =3D ? ERESTARTSYS (To be restart= ed if SA_RESTART is set) --- SIGWINCH {si_signo=3DSIGWINCH, si_code=3DSI_KERNEL} --- rt_sigreturn() =3D -1 EINTR (Interrupted system= call) read(0, bash in an xfce4-terminal: read(0, 0x7ffd51136837, 1) =3D ? ERESTARTSYS (To be restart= ed if SA_RESTART is set) --- SIGWINCH {si_signo=3DSIGWINCH, si_code=3DSI_KERNEL} --- rt_sigreturn() =3D 0 read(0, 0x7ffd51136837, 1) =3D ? ERESTARTSYS (To be restart= ed if SA_RESTART is set) [...] --- SIGWINCH {si_signo=3DSIGWINCH, si_code=3DSI_KERNEL} --- rt_sigreturn() =3D 0 read(0, 0x7ffd51136837, 1) =3D ? ERESTARTSYS (To be restart= ed if SA_RESTART is set) --- SIGWINCH {si_signo=3DSIGWINCH, si_code=3DSI_KERNEL} --- rt_sigreturn() =3D 0 read(0, 0x7ffd51136837, 1) =3D ? ERESTARTSYS (To be restart= ed if SA_RESTART is set) --- SIGWINCH {si_signo=3DSIGWINCH, si_code=3DSI_KERNEL} --- rt_sigreturn() =3D 0 read(0, regards, mike