Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

effects of GAP's Browse on Julia's screen output? #741

Open
ThomasBreuer opened this issue Oct 22, 2021 · 7 comments
Open

effects of GAP's Browse on Julia's screen output? #741

ThomasBreuer opened this issue Oct 22, 2021 · 7 comments

Comments

@ThomasBreuer
Copy link
Member

I am using Julia 1.6.3 with the develop version of GAP.jl.
The GAP package Browse has been installed via `GAP.Packages.load("Browse", install = true).

When I suspend the Julia session with Ctrl-Z and then enter the session again, the terminal gets cleared, the Julia prompt appears in the first line, and afterwards the distribution of Julia's output to lines does not fit anymore.
This problem disappears as soon as I deinstall the Browse package.

(This problem is sort of a continuation of #456, but since the effects are different, I opened a new issue instead of reopening #456.)

@fingolfin
Copy link
Member

A wild guess: julia seems to implement its own Ctrl-Z handling (see stdlib/REPL/src/LineEdit.jl in the Julia sources, search for suspend). Perhaps loading ncurses disables it (enables the default SIGSTP handling / disables a signal mask blocking SIGSTP / whatever), and that wrecks things?

@fingolfin
Copy link
Member

fingolfin commented Oct 23, 2021

From the ncurses file ncurses/tty/lib_tstp.c:

 * This is invoked once at the beginning (e.g., from 'initscr()'), to
 * initialize the signal catchers, and thereafter when spawning a shell (and
 * returning) to disable/enable the SIGTSTP (i.e., ^Z) catcher.
 *
 * If the application has already set one of the signals, we'll not modify it
 * (during initialization).
 *
 * The XSI document implies that we shouldn't keep the SIGTSTP handler if
 * the caller later changes its mind, but that doesn't seem correct.

I am pretty sure this interferes with Julia, which also kinda wants to control the screen...

Now, we could certainly perform some tricks to deal with this (e.g. set up a temporary SIGTSTP handlers before calling initscr, then removing it afterwards). But of course there is a reason ncurses handles that signal. I guess this would manifest if one tries Ctrl-Z while Browse is showing some ncurses "graphics"

@fingolfin
Copy link
Member

It seems that pressing ctrl-z while Browse is active is somewhat broken even in regular GAP. E.g. when I enter ?Quotient I am showing a pager list of help items to select; pressing ctrl-z here doesn't work very well. But in contrast, once I've selected a specific help item, ctrl-z works nicely. Huh.

@ThomasBreuer
Copy link
Member Author

I think we have to distinguish three different situations:

  • If Browse has not yet been loaded then Ctrl-Z has its default behaviour.
  • If Browse has beed loaded then some initialization has happened, and we get the effects sketched in the beginning of this discussion.
  • If the visual mode of ncurses is active, the behaviour of Ctrl-Z is apparently different.

Concerning the example mentioned above:
Entering ?Quotient at the gap> prompt starts a Browse application if Browse is loaded, and then ncurses' visual mode is active. After entering Ctrl-Z, one is back at the shell prompt, but the cursor is still hidden. Calling fg takes one back to the application, but no redraw of the screen is triggered. (I have never thought about whether we could deal better with this situation.)
If one selects one of the entries shown in the window that appears when one enters ?Quotient then ncurses' visual mode gets switched off, and the text is shown in a GAP pager, which is not based on ncurses.

@paemurru
Copy link

When I suspend the Julia session with Ctrl-Z and then enter the session again, the terminal gets cleared

The same behaviour occurs when using OSCAR without any other packages.

@fieker
Copy link
Contributor

fieker commented Mar 12, 2024 via email

@fingolfin
Copy link
Member

The browse package is unconditionally calling initscr() when starting up, which I believe is the root cause for the issue. This is also the cause of gap-system/gap#430 (CC @ThomasBreuer )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants