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

guioptions+=!, sighup and hit-enter with system() #3327

Closed
lilydjwg opened this issue Aug 14, 2018 · 8 comments
Closed

guioptions+=!, sighup and hit-enter with system() #3327

lilydjwg opened this issue Aug 14, 2018 · 8 comments

Comments

@lilydjwg
Copy link
Contributor

There are two issues that has been with me for a long time.

The first: hit-enter after calling system().

  1. gvim --clean to start
  2. set go=acit! (I don't know the exact conbinations for the issue to occur yet.)
  3. let a = system('ls'), and you'll get a "hit-enter" prompt.

This is a blocker issue for vim-racer, because this completer will call system() to get completions, and "hit-enter"s break typing. Sometimes I see a "^R" line shown after pressing enter.

The second: SIGHUP for background commands.

  1. gvim --clean to start
  2. set go+=!
  3. call system("firefox https://www.vim.org/ &")
  4. Nothing happens. The firefox process was killed by SIGHUP. Even I prefix it with nohup, nohup itself was killed before it fully set itself up.

Vim version 8.1.278 huge build with gtk2 GUI, on Arch Linux.

Full `--version` output
VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 13 2018 02:50:50)
Included patches: 1-278
Modified by me
Compiled by me@mymachine
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            +farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    -tcl
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
+balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
+browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          +toolbar
+cindent           +insert_expand     +path_extra        +user_commands
+clientserver      +job               +perl/dyn          +vartabs
+clipboard         +jumplist          +persistent_undo   +vertsplit
+cmdline_compl     +keymap            +postscript        +virtualedit
+cmdline_hist      +lambda            +printer           +visual
+cmdline_info      +langmap           +profile           +visualextra
+comments          +libcall           +python/dyn        +viminfo
+conceal           +linebreak         +python3/dyn       +vreplace
+cryptv            +lispindent        +quickfix          +wildignore
+cscope            +listcmds          +reltime           +wildmenu
+cursorbind        +localmap          +rightleft         +windows
+cursorshape       +lua/dyn           +ruby/dyn          +writebackup
+dialog_con_gui    +menu              +scrollbind        +X11
+diff              +mksession         +signs             -xfontset
+digraphs          +modify_fname      +smartindent       +xim
+dnd               +mouse             +startuptime       -xpm
-ebcdic            +mouseshape        +statusline        +xsmp_interact
+emacs_tags        +mouse_dec         -sun_workshop      +xterm_clipboard
+eval              +mouse_gpm         +syntax            -xterm_save
+ex_extra          -mouse_jsbterm     +tag_binary        
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/uuid -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -pthread  -D_FORTIFY_SOURCE=2  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.28/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype  -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.28/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/5.28/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc        
@lifepillar
Copy link
Contributor

The first: hit-enter after calling system().

How about:

silent let a = system('ls')

@lilydjwg
Copy link
Contributor Author

silent does prevent the hit-enter prompt. But it means I have to patch (potentially a lot of) 3rd party plugins.

@chdiza
Copy link

chdiza commented Aug 14, 2018

The first issue happens in MacVim too, FYI.

@chrisbra
Copy link
Member

I had a look. It happens because do_cmdline() is called recursively. BTW: I noticed that a bunch of autocommands are executed when using :set guioptions+=! like BufAdd, BufEnter, and then WinLeave, BufDelete. I think we could skip those at least for system().

Thinking a bit more about the system() case, is there a reason, we don't simply set no_wait_return when executing the system() function? At least in that case we don't expect any output to be displayed directly, right?

@brammool
Copy link
Contributor

brammool commented Sep 21, 2018 via email

@chrisbra
Copy link
Member

I suppose that comes from the output in the (hidden) terminal window.

@lixiao-t4f
Copy link

vim/src/os_unix.c

Line 5477 in 7db3a8e

if (gui.in_use && vim_strchr(p_go, GO_TERMINAL) != NULL)

I guess this is where system() is affected by 'go-!'.

If so, what about always skipping terminal for system()? Since system() is not meant to be used interactively, an interactive terminal is not needed.

I go into this issue, since I have autocmd defined in InsertLeavePre, which calls system(), fails when in cmdwin; I think lilydjwg's fcitx.vim plugin is also affected by this issue.

MRE: in command mode, press <C-f> to enter cmdwin, then press i to enter cmdwin insert mode and press <Esc> to leave. E1188 (open terminal fail) and E282 (read tempfile fail) will be trigger.

@lixiao-t4f
Copy link

E282 is raised, maybe because I define related function / autocmd in my vimrc. Sorry for the incorrect comment.

Also, E1188 is more about command-line window, not terminal window.

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

6 participants