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

fixed hang issue with --headless and -r option specified #12209

Merged
merged 8 commits into from
May 20, 2020

Conversation

Code-Hex
Copy link
Contributor

@Code-Hex Code-Hex commented Apr 29, 2020

fixed #11386 issues.

Calling the do_more_prompt function in headless mode will freeze neovim because it is eventally in the input-accepting state (the same as waiting for --more--).

I have tried

  • nvim -u NORC -c 'for i in range(0, 1000) | echo i | endfor | quit' --headless
  • nvim -u NORC -r

Calling the do_more_prompt function in headless mode will freeze neovim because it is eventally in the input-accepting state (the same as waiting for --more--).
@Code-Hex
Copy link
Contributor Author

By the way, I think this "Press ENTER or type command to continue" message shouldn't be output in headless mode spec, is my understanding correct?

$ nvim -u NORC -c 'ls' --headless

  1 %a   "[No Name]"                    line 0
Press ENTER or type command to continue

@glacambre
Copy link
Member

By the way, I think this "Press ENTER or type command to continue" message shouldn't be output in headless mode spec, is my understanding correct?

Yes, there's even an issue for this: #9358 :).

@Code-Hex
Copy link
Contributor Author

A lot of tests have failed...
I think it's due to a lot of tests relying on headless mode. I think we need to work on replacing "Expected" and "Actual", but I can't judge if it's really correct... 😢

How should I do this?

If in headless mode, we need to exit at this point. If we continue, we will enter the normal mode and the message "Press ENTER or type command to continue" will be displayed and we will be in the input waiting state.
@justinmk
Copy link
Member

justinmk commented May 1, 2020

thanks for tracking this down!

think we need to work on replacing "Expected" and "Actual", but I can't judge if it's really correct..

where? on travis I only see this:

�[32m�[2m[ RUN      ]�[0m�[0m startup defaults :filetype late `:filetype … off` stays OFF: -- Tests exited non-zero: SIGPIPE
-- No output to stderr.
CMake Error at /home/travis/build/neovim/neovim/cmake/RunTests.cmake:85 (message):
  functional tests failed with error: SIGPIPE

@justinmk justinmk added this to the 0.5 milestone May 1, 2020
@justinmk justinmk added the startup Nvim startup sequence (`:h startup`) label May 1, 2020
src/nvim/main.c Outdated
if (headless_mode) {
msg_putchar('\n');
return 0;
}
Copy link
Member

@justinmk justinmk May 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably isn't the right approach. maybe leave this for a separate PR.

headless mode should proceed through normal mode as usual, we can't assume that it should exit here. E.g. some clients may want to connect while nvim --headless runs as a server. Nvim should exit only if :q command (or equivalent) was issued.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

I understand. I quit to touch this issue (I will focus only for “more”)

@Code-Hex
Copy link
Contributor Author

Code-Hex commented May 3, 2020

@justinmk I think it was difficult. I will try to fix it

@Code-Hex Code-Hex requested a review from justinmk May 3, 2020 10:30
@Code-Hex
Copy link
Contributor Author

Code-Hex commented May 3, 2020

@justinmk The main issue has been fixed. Re-review, please!

Comment on lines +290 to +295
-- FIXME(codehex): We should really set a timeout for the system function.
-- If this test fails, there will be a waiting input state.
funcs.system({nvim_prog, '-u', 'NONE', '-c',
'for i in range(1, 100) | echo i | endfor | quit',
'--headless'
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I didn't think an idea...

@Code-Hex
Copy link
Contributor Author

Code-Hex commented May 6, 2020

Probably, travis CI has been broken
https://travis-ci.org/github/neovim/neovim/jobs/683712510

Copy link
Contributor

@tjdevries tjdevries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran this PR on my local machine and it fixed the exact problem I was having w/ headless mode pausing when I had "a lot" of output.

@justinmk I don't merge C code though as a rule ;) So it's up to you. I have no idea if this is the right fix or not given other factors.

@glacambre
Copy link
Member

This PR also closes #12299, that's pretty cool!

@Code-Hex
Copy link
Contributor Author

CI has been passed. (I tried force-push to rerun CI)

@tjdevries
Copy link
Contributor

OK, I'll merge tomorrow if I don't hear any complaints. It looks good to me and is a very small change and tests pass. So seems fine to merge

@Code-Hex
Copy link
Contributor Author

@tjdevries merge? 🙏

@tjdevries tjdevries merged commit c6dc397 into neovim:master May 20, 2020
@tjdevries
Copy link
Contributor

@Code-Hex Thanks for fixing and thanks for the ping. I actually need this for a plugin I'm working on anyway, so I can't deny some selfish motives to checking out the PR myself and running the tests ;)

jamessan pushed a commit to jamessan/neovim that referenced this pull request May 21, 2020
* fixed hang issue with --headless and -r option specified

Calling the do_more_prompt function in headless mode will freeze neovim because it is eventally in the input-accepting state (the same as waiting for --more--).

* fixed "Press ENTER or type command to continue" to be suppressed

If in headless mode, we need to exit at this point. If we continue, we will enter the normal mode and the message "Press ENTER or type command to continue" will be displayed and we will be in the input waiting state.

* fixed functional ex_cmds tests

* Revert "fixed "Press ENTER or type command to continue" to be suppressed"

This reverts commit a02dc40.

* Revert "fixed functional ex_cmds tests"

This reverts commit 3bdb8da.

* fixed conditional again

* added test for fixed hang issue with --headless (neovim#11386)

(cherry picked from commit c6dc397)
farisachugthai pushed a commit to farisachugthai/neovim that referenced this pull request Aug 4, 2020
* fixed hang issue with --headless and -r option specified

Calling the do_more_prompt function in headless mode will freeze neovim because it is eventally in the input-accepting state (the same as waiting for --more--).

* fixed "Press ENTER or type command to continue" to be suppressed

If in headless mode, we need to exit at this point. If we continue, we will enter the normal mode and the message "Press ENTER or type command to continue" will be displayed and we will be in the input waiting state.

* fixed functional ex_cmds tests

* Revert "fixed "Press ENTER or type command to continue" to be suppressed"

This reverts commit a02dc40.

* Revert "fixed functional ex_cmds tests"

This reverts commit 3bdb8da.

* fixed conditional again

* added test for fixed hang issue with --headless (neovim#11386)
jamessan added a commit that referenced this pull request Aug 5, 2020
Maintenance release for v0.4.x series.

FIXES:

fd02e63 #12701 ui: fix problem with sattr_T overflow
3e3002b #12710 fs: Ensure FileInfo struct is initialized
e4629f2 #12496 main.c: fix hang issue with recoverymode #12520
f558af8 #12209 fixed hang issue with --headless and -r option specified
cda1190 #12180 TUI: block signals on suspend
8399f73 #12142 Fix issues revealed by gcc10 setting -fno-common by default
5e47cf2 netrw.vim: do not save +/* registers
5d41bfc #11907 quickfix.c: Fix vimgrep regression
641e229 #11903 screen: add missing redraws after a message
47bd62c loop_close: close all handles
d273036 loop_close: call uv_stop(), fix bug
284b398 #11821 loop_close: timout after 2 seconds
1b2666c messages: echo "line1\r\nline2" should not clear line1
1bf90bf #11651 API: fix crash on copy_object(kObjectTypeWindow)
fafd636 #11566 libcallnr: Use int, not int64_t, as the return type for Vim compat
972dd75 #11460 win_line: Fix crash with 'rightleft' in :terminal
4c48cf3 f_getenv/setenv: Access v_special when v_type is VAR_SPECIAL
2cd1ff7 #11360 paste: Select-mode, Visual-mode
qvacua added a commit to qvacua/neovim that referenced this pull request Aug 12, 2020
NVIM v0.4.4

Maintenance release for v0.4.x series.

FIXES:

fd02e63 neovim#12701 ui: fix problem with sattr_T overflow
3e3002b neovim#12710 fs: Ensure FileInfo struct is initialized
e4629f2 neovim#12496 main.c: fix hang issue with recoverymode neovim#12520
f558af8 neovim#12209 fixed hang issue with --headless and -r option specified
cda1190 neovim#12180 TUI: block signals on suspend
8399f73 neovim#12142 Fix issues revealed by gcc10 setting -fno-common by default
5e47cf2 netrw.vim: do not save +/* registers
5d41bfc neovim#11907 quickfix.c: Fix vimgrep regression
641e229 neovim#11903 screen: add missing redraws after a message
47bd62c loop_close: close all handles
d273036 loop_close: call uv_stop(), fix bug
284b398 neovim#11821 loop_close: timout after 2 seconds
1b2666c messages: echo "line1\r\nline2" should not clear line1
1bf90bf neovim#11651 API: fix crash on copy_object(kObjectTypeWindow)
fafd636 neovim#11566 libcallnr: Use int, not int64_t, as the return type for Vim compat
972dd75 neovim#11460 win_line: Fix crash with 'rightleft' in :terminal
4c48cf3 f_getenv/setenv: Access v_special when v_type is VAR_SPECIAL
2cd1ff7 neovim#11360 paste: Select-mode, Visual-mode
landerlo pushed a commit to landerlo/neovim that referenced this pull request Nov 23, 2020
* fixed hang issue with --headless and -r option specified

Calling the do_more_prompt function in headless mode will freeze neovim because it is eventally in the input-accepting state (the same as waiting for --more--).

* fixed "Press ENTER or type command to continue" to be suppressed

If in headless mode, we need to exit at this point. If we continue, we will enter the normal mode and the message "Press ENTER or type command to continue" will be displayed and we will be in the input waiting state.

* fixed functional ex_cmds tests

* Revert "fixed "Press ENTER or type command to continue" to be suppressed"

This reverts commit a02dc40.

* Revert "fixed functional ex_cmds tests"

This reverts commit 3bdb8da.

* fixed conditional again

* added test for fixed hang issue with --headless (neovim#11386)
@Code-Hex Code-Hex deleted the fix/hang-headless-mode branch January 13, 2022 07:05
@dundargoc dundargoc removed the request for review from justinmk October 3, 2022 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
startup Nvim startup sequence (`:h startup`)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nvim -r hangs if the output is "too long"
5 participants