From: Mike Kupfer <mkupfer@alum.berkeley.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Stephen Berman <stephen.berman@gmx.net>, emacs-devel@gnu.org
Subject: Re: misbehavior in shell window with ksh
Date: Thu, 04 May 2017 20:04:03 -0700 [thread overview]
Message-ID: <914.1493953443@alto> (raw)
In-Reply-To: Your message of "Thu, 04 May 2017 17:42:59 +0300." <8337ckhedo.fsf@gnu.org>
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=SIGWINCH, si_code=SI_KERNEL} ---
rt_sigaction(SIGWINCH, {0x41c250, [], SA_RESTORER|SA_INTERRUPT, 0x7f91cb7cd0e0}, {0x41c250, [], SA_RESTORER|SA_INTERRUPT, 0x7f91cb7cd0e0}, 8) = 0
ioctl(2, TIOCGWINSZ, {ws_row=25, ws_col=80, ws_xpixel=0, ws_ypixel=0}) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], NULL, 8) = 0
rt_sigreturn() = -1 EINTR (Interrupted system call)
write(2, "\r", 1) = 1
ioctl(2, TIOCGWINSZ, {ws_row=25, ws_col=80, ws_xpixel=0, ws_ypixel=0}) = 0
poll(0x7ffcc1e41dc0, 0, 50) = 0 (Timeout)
ioctl(2, TIOCGWINSZ, {ws_row=25, ws_col=80, ws_xpixel=0, ws_ypixel=0}) = 0
write(2, "\ralto$ ", 7) = 7
select(1, [0], NULL, NULL, NULL) = ? ERESTARTNOHAND (To be restarted if no handler)
Its behavior in a shell buffer is similar, except it just writes out the
PS2 prompt.
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
rt_sigaction(SIGWINCH, {0x41c250, [], SA_RESTORER|SA_INTERRUPT, 0x7fc02802d0e0}, {0x41c250, [], SA_RESTORER|SA_INTERRUPT, 0x7fc02802d0e0}, 8) = 0
ioctl(2, TIOCGWINSZ, {ws_row=32, ws_col=78, ws_xpixel=0, ws_ypixel=0}) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], NULL, 8) = 0
rt_sigreturn() = -1 EINTR (Interrupted system call)
ioctl(2, TIOCGWINSZ, {ws_row=32, ws_col=78, ws_xpixel=0, ws_ypixel=0}) = 0
poll(0x7ffc9eb5abf0, 0, 50) = 0 (Timeout)
ioctl(2, TIOCGWINSZ, {ws_row=32, ws_col=78, ws_xpixel=0, ws_ypixel=0}) = 0
select(1, [0], NULL, NULL, {0, 0}) = 0 (Timeout)
write(2, "> ", 2) = 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) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
rt_sigreturn() = -1 EINTR (Interrupted system call)
read(0, <detached ...>
bash in an xfce4-terminal:
read(0, 0x7ffd51136837, 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
rt_sigreturn() = 0
read(0, 0x7ffd51136837, 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
[...]
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
rt_sigreturn() = 0
read(0, 0x7ffd51136837, 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
rt_sigreturn() = 0
read(0, 0x7ffd51136837, 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
rt_sigreturn() = 0
read(0, <detached ...>
regards,
mike
next prev parent reply other threads:[~2017-05-05 3:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-30 23:12 misbehavior in shell window with ksh Mike Kupfer
2017-05-01 6:49 ` Eli Zaretskii
2017-05-01 10:59 ` Stephen Berman
2017-05-01 11:31 ` Eli Zaretskii
2017-05-01 14:41 ` Stephen Berman
2017-05-01 15:09 ` Eli Zaretskii
2017-05-01 15:52 ` Stephen Berman
2017-05-02 9:03 ` Eli Zaretskii
2017-05-02 12:35 ` Stephen Berman
2017-05-02 16:32 ` Eli Zaretskii
2017-05-02 16:55 ` Stephen Berman
2017-05-03 17:51 ` Eli Zaretskii
2017-05-04 7:54 ` Stephen Berman
2017-05-04 14:42 ` Eli Zaretskii
2017-05-05 3:04 ` Mike Kupfer [this message]
2017-05-05 6:13 ` Eli Zaretskii
2017-05-06 18:41 ` Mike Kupfer
2017-05-09 16:36 ` Eli Zaretskii
2017-05-01 15:29 ` Mike Kupfer
2017-05-02 13:03 ` Tino Calancha
2017-05-01 7:38 ` Tino Calancha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=914.1493953443@alto \
--to=mkupfer@alum.berkeley.edu \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=stephen.berman@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.