bugGNU Screen - Bugs: bug #49883, Run mc inside screen + resize...


bug #49883: Run mc inside screen + resize terminal + ctrl-a esc + pgup pgup pgup = bug

Submitted by:  Askar Safin <safinaskar>
Submitted on:  Mon 19 Dec 2016 01:42:30 AM UTC  
Category: Program LogicSeverity: 3 - Normal
Priority: 5 - NormalStatus: Confirmed
Privacy: PublicAssigned to: Amadeusz Sławiński <amade>
Open/Closed: OpenRelease: 4.4.0
Fixed Release: NonePlanned Release: 4.6.0
Work Required: None

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Sat 15 Jul 2017 02:14:28 PM UTC, comment #9:


Since upgrading to screen 4.6.0 I have having issues with cursor placement after leaving altscreen. I looked through the history and found commit 8062db33b87ed86ec54222c83babbf1aa5866ec9, which refers to this bug. Reverting that commit fixes the problem.

Steps to reproduce:
1. Start screen with altscreen on
2. Press enter at your shell prompt until you reach the bottom of the screen
3. Run 'echo foo | less'
4. Press 'q' to exit

Expected behaviour:
The cursor should be at the bottom of the screen, just like it was before I started less.

Actual behaviour:
The cursor is in the middle of my history, somewhere near the top of the screen.

I'm running Arch Linux, up to date as of today. less 487, screen 4.6.1, ncurses 6.0+20170527, glibc 2.25, Linux 3.16.45.

Happy to test any patches, thanks!

James Bunton <delx>
Thu 13 Apr 2017 08:53:13 AM UTC, comment #8:

Uh.. right, reopen, while I work on another fix...

Amadeusz Sławiński <amade>
Project AdministratorIn charge of this item.
Tue 11 Apr 2017 08:32:18 AM UTC, comment #7:

I tested again.
"altscreen on" really (something like) ignored now.

Steps I used.

My host system is debian stretch. I run this command (to create chroot environment with another debian stretch in it):

$ sudo debootstrap --variant=minbase stretch /tmp/s http://ftp.debian.org/debian

Then, in newly created system:

# apt-get install mc
# apt-get install gcc make git
# git clone https://git.savannah.gnu.org/git/screen.git # commit a48e1f96dc329cd0fc28ed91890dd19f4d12a47c
# cd screen
# cd src
# apt-get install automake autoconf
# ./autogen.sh
# apt-get install libc6-dev
# apt-get install libncurses5-dev
# ./configure --prefix=/opt/screen-2017-04-11
# make
# make install
# apt-get install systemd-sysv systemd
# passwd -d root

Then, at host we boot this chroot environment using systemd-nspawn:

$ sudo systemd-nspawn -bD /tmp/s

Then, in newly booted container:

# mcedit ~/.screenrc
# cat ~/.screenrc
altscreen on
startup_message off
# /opt/screen-2017-04-11/bin/screen

Then I see "startup_message off" took effect (so, screen uses this config), but "altscreen on" is ignored.

If you want, I can send you this chroot environment.


Also, I just noticed this: your example works. I. e. if I run big "ls" and then "mc", then "altscreen" works. But if I type "mc" as first in command in screen, then "altscreen" doesn't work (unlike stretch's version, i. e. "Screen version 4.04.00 (GNU) 19-Jun-16")

Askar Safin <safinaskar>
Sun 09 Apr 2017 09:42:00 AM UTC, comment #6:


not sure what happened, but either you must have accidentally done something wrong or I need better steps, as for me it seems to work just fine.

After I do 'ls -la' and then run 'mc' output of ls still stays in view, all with one line config (altscreen on).

-rw-r--r-- 1 amade amade 2674 04-09 11:26 winmsgbuf.h
-rw-r--r-- 1 amade amade 24088 04-09 11:27 winmsgbuf.o
-rw-r--r-- 1 amade amade 3386 04-09 11:26 winmsgcond.c
-rw-r--r-- 1 amade amade 1525 04-09 11:26 winmsgcond.h
-rw-r--r-- 1 amade amade 8416 04-09 11:27 winmsgcond.o
amade@pecet ~/workdir/gnu/screen/src $ mc

amade@pecet ~/workdir/gnu/screen/src $

Amadeusz Sławiński <amade>
Project AdministratorIn charge of this item.
Sat 08 Apr 2017 08:01:34 PM UTC, comment #5:

Now "altscreen on" doesn't work.

I built current master, installed it to /opt/screen-2017-04-08 , then added "altscreen on" to ~/.screenrc and /etc/screenrc , then I run /opt/screen-2017-04-08/bin/screen -c ~/.screenrc , but "altscreen on" has no effect.

I run screen, then I run mc inside it, then I exit from mc and I see a lot of empty space before prompt exactly as in very first message in this bug report.

Askar Safin <safinaskar>
Thu 06 Apr 2017 09:37:21 AM UTC, comment #4:

So did some more thinking and applied better fix.
Available in both screen-v4 and master branches.
Will be in next release.

Amadeusz Sławiński <amade>
Project AdministratorIn charge of this item.
Thu 12 Jan 2017 03:19:28 PM UTC, comment #3:

Confirmed, when using altscreen we restore cursor position before we leave altscreen.This was changed by https://savannah.gnu.org/bugs/?35757 so we don't want to break this. Easiest fix seems to be to restore cursor position before and after leaving altscreen.

Will have a fix ready after some testing.

Amadeusz Sławiński <amade>
Project AdministratorIn charge of this item.
Tue 10 Jan 2017 01:06:37 AM UTC, comment #2:

Thanks, now described bugs disappeared.
But now appeared that tmux bug I just described as "be careful not to introduce". I will try to repeat it simpler.

  • Start screen (with altscreen on)
  • Type into it: "for ((I = 1; I <= 100; ++I)) { echo $I; }; mc" and press Enter
  • Make the terminal (for example, gnome-terminal) 3 (or more) lines smaller vertically
  • f10 (or esc 0) (exit from mc)

Now I see:

2017-01-10 04:04:05 ~$

And I expected to see:

2015-07-09 19:38:32 ~$ _

Askar Safin <safinaskar>
Mon 09 Jan 2017 09:11:24 PM UTC, comment #1:


can you add
altscreen on
to your .screenrc and check if you still have problems. Seems to me like you don't have this setting enabled.

Amadeusz Sławiński <amade>
Project AdministratorIn charge of this item.
Mon 19 Dec 2016 01:42:30 AM UTC, original submission:

(All described behavior happens in "normal" terminal such as gnome-terminal and not in "dumb" terminal such as linux console)

Run screen, then run mc in it, then exit from mc. You will see this:

[ Lot of empty space ]
$ _

So, all previous commands and their output moved up (to scrollback) and now they are accessible using ctrl-a esc only. What should be instead? Instead terminal should come to state in which it was before mc startup. I. e. all output should be here. I should see this:

$ mc

$ _

I. e. I should see "mc" command I used to run mc, then one empty line and the current line with cursor. I. e. I should see same that happen without screen involved. tmux has no this bug.

Okey, now let me say about next bug. Open screen, then open mc inside it. Then resize your outer terminal (this will cause resizing of screen, of course). Then exit from mc, type ctrl-a esc and type pgup several times. You will see that your scrollback contains a lot of copies of mc (with different sizes). This is wrong. Scrollback should contain same text it contained before starting of mc. Again, tmux has no this bug.

But when fixing this bug be careful not to introduce yet another bug. tmux has bug:

  • Start tmux
  • Type into it: "for ((I = 1; I <= 100; ++I)) { echo $I; }; mc" and press Enter
  • Ctrl-b " (tell tmux to open new pane, this will make mc smaller)
  • Ctrl-b ; (tell tmux to switch to top pane, i. e. to mc)
  • f10 (or esc 0) (exit from mc)

Now I see:


34 2015-07-09 19:38:32 ~$ _

And I expected to see:


34 2015-07-09 19:38:32 ~$ _

So, tmux "eats" numbers 84..100.
So, tmux has this bug and screen has not. When you fix bugs described at the beginning of this report, be careful not to introduce this tmux's bug I described here.

$ screen --version
Screen version 4.04.00 (GNU) 19-Jun-16

Askar Safin <safinaskar>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by delx (Posted a comment)
  • -unavailable- added by amade (Posted a comment)
  • -unavailable- added by safinaskar (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 13 Apr 2017 08:53:13 AM UTCamadeStatusFixed=>Confirmed
    Thu 06 Apr 2017 09:37:21 AM UTCamadeStatusConfirmed=>Fixed
      Planned ReleaseNone=>4.6.0
    Thu 12 Jan 2017 03:19:28 PM UTCamadeStatusNeed Info=>Confirmed
      Assigned toNone=>amade
    Mon 09 Jan 2017 09:11:24 PM UTCamadeStatusNone=>Need Info

    Back to the top

    Powered by Savane 3.1-cleanup1