gap icon indicating copy to clipboard operation
gap copied to clipboard

CTRL-Z crashes the GAP session

Open BNasmith opened this issue 7 years ago • 11 comments

I have a bad habit of hitting CTRL-Z when I make a mistake typing something. When I do this in a GAP session, it seems to freeze the session. I can't even close the window by clicking the top right corner. I have to find another way to close the GAP session window and start again.

I'd expect that CTRL-Z might do nothing, if it isn't going to undo a mistake.

Here's my setup, thanks!

 ┌───────┐   GAP 4.9.3 of 05-Sep-2018
 │  GAP  │   https://www.gap-system.org
 └───────┘   Architecture: i686-pc-cygwin-default32
 Configuration:  gmp 6.0.0, readline
 Loaded workspace: default
 Packages:   AClib 1.3, Alnuth 3.1.0, AtlasRep 1.5.1, AutPGrp 1.10, Browse 1.8.8, CRISP 1.4.4, Cryst 4.1.17,
             CrystCat 1.1.8, CTblLib 1.2.2, FactInt 1.6.2, FGA 1.4.0, GAPDoc 1.6.1, IO 4.5.2, IRREDSOL 1.4,
             LAGUNA 3.9.0, Polenta 1.3.8, Polycyclic 2.14, PrimGrp 3.3.1, RadiRoot 2.8, ResClasses 4.7.1,
             SmallGrp 1.3, Sophus 1.24, SpinSym 1.5, TomLib 1.2.6, TransGrp 2.0.4, utils 0.57
 Try '??help' for help. See also '?copyright', '?cite' and '?authors'

BNasmith avatar Sep 28 '18 00:09 BNasmith

My best guess is that this is something Windows specific -- I constantly use ctrl-Z on Mac OS X to put my GAP session into the background, then resume it using fg.

How did you start GAP? From a terminal? Or from a start menu entry or so? In the latter case, perhaps (as somebody who almost never uses Windows, I am merely wildly guessing) the problem might be that there is no underlying shell in which GAP runs -- so of course if one suspends it, there is no other process that could come to the foreground, resulting into the problem...

Anyway, hopefully @ChrisJefferson or @alex-konovalov know more.

fingolfin avatar Sep 28 '18 13:09 fingolfin

I have git install on Windows and load GAP by typing $ gap.bat in bash.

BNasmith avatar Sep 28 '18 18:09 BNasmith

If you compiled it yourself, then in bash you should be able to start it with gap.sh instead of gap.bat - could you please try that and check what happens when you press ctrl-Z?

olexandr-konovalov avatar Sep 28 '18 23:09 olexandr-konovalov

I installed GAP by running the gap-4.9.3.exe file from the downloads page. When I try to run gap.sh from a prompt (whether bash of cmd) it won't properly open GAP and shuts down after a brief attempt. I seem to need to run gap.bat instead.

However, I just tried running gapcmd.bat from the Command Prompt, rather than bash, and in that setting CTRL-Z does not cause a problem.

BNasmith avatar Sep 29 '18 02:09 BNasmith

@BNasmith thanks for clarifying - you wrote "git install on Windows" so I've assumed that you've compiled it yourself. If this is not the case, then gap.sh can not be used to start GAP.

However, both gap.bat and gapcmd.bat can be started in Command Prompt - there is no limitation that the former has to be started only in bash. Also, you can navigate to the directory in the graphical file explorer and then double-click on gap.bat to start it. It will be interesting to see if it will react differently on ctrl-Z in this case.

olexandr-konovalov avatar Sep 29 '18 08:09 olexandr-konovalov

P.S. I've logged in into a remote Windows VM and can reproduce this, starting GAP by double-clicking on the file in the GUI. It freezes, and does not respond on attempts to close it. I've only managed to close it by closing the auxiliary window hidden beneath it.

olexandr-konovalov avatar Sep 29 '18 09:09 olexandr-konovalov

Yes, thanks. I meant to write "git installed" not "git install", a typo. I just tried double clicking gap.bat and I can reproduce the problem that way. CTRL-Z freezes the session and the only way to close it seems to be to close the auxillary window. However, gapcmd.bat doesn't suffer from the same problem (and doesn't include an auxillary window).

BNasmith avatar Sep 29 '18 11:09 BNasmith

@BNasmith sorry, I still do not understand what do you mean by "git installed" here, if you have used the gap-4.9.3.exe installer from the GAP downloads page. How is git involved in the installation process?

If gapcmd.bat works, that may be acceptable, although I found mintty shell (i.e. the one started by gap.bat) more convenient and permitting flexible customisations as explained e.g. at https://github.com/gap-system/GapWWW/issues/100 - that's why it's now the default way to run GAP under Windows.

Also, regarding UNDO functionality in GAP: https://www.gap-system.org/Manuals/doc/ref/chap6.html#X82234FD181899530 says that Ctrl-_ (i.e. Control-underscore) may be used for UNDO.

olexandr-konovalov avatar Sep 29 '18 14:09 olexandr-konovalov

That’s all helpful, thanks. (I just mentioned having installed git to explain why I’m using bash, that’s all). I’ll check out mintty and am happy using gapcmd until then. I appreciate it.

BNasmith avatar Sep 29 '18 20:09 BNasmith

We could fairly easily disable ctrl+z, but users who run GAP through bash often use ctrl+z to pause GAP. I don't know if/how we can detect the special case of GAP being run from a .bat file.

I think I have an idea how to fix this, but it won't get fixed until 4.11.

ChrisJefferson avatar Sep 30 '18 12:09 ChrisJefferson

This still happens -- but will be looked at after 4.12 is released as I don't want to break anything so close to the release.

ChrisJefferson avatar Aug 17 '22 11:08 ChrisJefferson

@ChrisJefferson did you ever have a chance to look into this?

fingolfin avatar Oct 17 '23 07:10 fingolfin

As I understand it, the problem is that if GAP is launched via a certain Windows shortcut we install, then there is no bash running "under" GAP -- so pressing ctrl-z, which normally temporarily returns one to the shell from which one launched GAP cannot do that, because, well, GAP was not launched from a shell. As a result, it just freezes.

This sounds to me as if ideally the "shortcut" which starts GAP should be modified in a way to ensure that ctrl-z is ignored -- be it by passing an argument to GAP to tell it to do that, or by some other means -- e.g. I think in a bash script, you can also disable certain signals, so perhaps this can be done this way...

Either way, the idea is that if a "power user" starts GAP from a terminal, they should of course still be able to use ctrl-z.

fingolfin avatar Oct 17 '23 07:10 fingolfin

There is a fix for this over on the windows packaging -- I just disable ctrl+z when GAP is run from the default script

https://github.com/gap-system/gap-windows/pull/6

ChrisJefferson avatar Oct 24 '23 05:10 ChrisJefferson

Should be resolved by https://github.com/gap-system/gap-windows/pull/6

fingolfin avatar Jan 10 '24 09:01 fingolfin