Vim-fork focused on extensibility and usability
Go to file
Justin M. Keyes 8a782f1699 input: set input stream to blocking on exit
If stdin is non-blocking, many tools (e.g. cat(1), read(1)) which assume
that stdin is blocking, will break in odd ways:

  read: read error: 0: Resource temporarily unavailable
  cat: -: Resource temporarily unavailable
  rm: error closing file

libuv puts stdin in nonblocking mode, and leaves it that way at exit
(this is apparently by design). So, before this commit, this always
works (because the shell clobbers O_NONBLOCK):

  $ nvim --cmd q
  $ read

...but these forms do _not_ work:

  $ nvim --cmd q && read
  $ echo foo | nvim --cmd q && read
  $ nvim && read

After this commit, all of the above forms work.

Background:

437b4397b9 (diff-41f4d294430cd8c36538999d62681ae2)
https://github.com/fish-shell/fish-shell/issues/176#issuecomment-15800155

- bash (and other shells: zsh, tcsh, fish), upon returning to the
  foreground, always sets fd 0 back to blocking mode. This practice only
  applies to stdin, _not_ stdout or stderr (in practice these fds may be
  affected anyways).
- bash/zsh/tcsh/fish do _not_ restore the non-blocking status of stdin
  when _resuming a job_.
- We do _not_ save/restore the original flags visible to
  fcntl(F_[SG]ETFL), because (counterintuitively) that isn't expected.

Helped-by: oni-link <knil.ino@gmail.com>

Closes #2086
Closes #2377

---

Note: The following implementation of stream_set_blocking() was
discarded, because it resulted in a failed libuv assertion[1]:

  int stream_set_blocking(int fd, bool blocking)
  {
    uv_pipe_t stream;
    uv_pipe_init(uv_default_loop(), &stream, 0);
    uv_pipe_open(&stream, fd);
    int retval = uv_stream_set_blocking((uv_stream_t *)&stream, blocking);
    uv_close((uv_handle_t *)&stream, NULL);
    return retval;
  }

[1] .deps/build/src/libuv/src/unix/core.c:833: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
2015-05-27 09:32:31 -04:00
.ci Travis: Add Mingw third-party builds 2015-05-15 17:55:02 +03:00
cmake Build: Use GNUInstallDirs, install man pages #2649 2015-05-17 14:57:43 -04:00
config cmake: Remove unneeded platform checks 2015-05-21 23:16:40 +01:00
contrib contrib: Update local.mk 2015-05-13 17:37:19 -04:00
man Remove -T command-line option 2015-05-18 11:06:54 -04:00
runtime 'cpoptions': Remove "j" flag 2015-05-25 16:29:00 -04:00
scripts Fix compiling with gcc 5. #2566 2015-05-04 23:23:06 -04:00
src input: set input stream to blocking on exit 2015-05-27 09:32:31 -04:00
test tests: Convert legacy test29 2015-05-25 16:29:01 -04:00
third-party cmake: Use cmake -E touch instead of touch #2730 2015-05-24 02:22:32 -04:00
.gitignore legacy tests: Remove legacy tests for Lua (test85) #2357 2015-04-06 01:49:36 -04:00
.travis.yml Travis: Add Mingw third-party builds 2015-05-15 17:55:02 +03:00
.valgrind.supp job: Refactor process spawning and startup arguments 2015-02-23 21:43:33 -03:00
appveyor.yml AppVeyor: MSVC builds for third-party/ 2015-05-15 17:55:02 +03:00
BACKERS.md Remove duplicates in BACKERS.md #2363 2015-04-06 15:43:31 -04:00
clint-ignored-files.txt Cleanup misc. 2015-05-18 11:06:54 -04:00
clint.py Change neovim.org references to neovim.io 2015-04-19 17:17:45 -03:00
CMakeLists.txt build: Limit --coverage flag to files under "src" 2015-05-18 04:28:01 -03:00
CONTRIBUTING.md CONTRIBUTING.md: Fix broken links #2702 2015-05-19 17:06:22 -04:00
Doxyfile update theme to match neovim.org 2014-06-19 11:53:57 +02:00
LICENSE LICENSE: add LuaJIT notice. #899 2014-06-30 13:59:56 -04:00
Makefile vim-patch:7.4.497 #2295 2015-04-05 19:24:58 -04:00
neovim.rb Homebrew: move formula to neovim/homebrew-neovim 2014-11-09 20:14:01 +08:00
README.md README: Add AppVeyor badge. #2691 2015-05-18 11:03:48 -04:00
uncrustify.cfg spelling fixes #827 2014-06-12 20:26:35 -04:00

Neovim

Website | Community | Wiki | Documentation | Mailing List | Twitter | Bountysource

Travis Build Status AppVeyor Build status Pull requests waiting for review Coverage Status Coverity Scan Build Clang Scan Build Join the chat at https://gitter.im/neovim/neovim

Neovim is a project that seeks to aggressively refactor Vim in order to:

  • Simplify maintenance and encourage contributions
  • Split the work between multiple developers
  • Enable the implementation of new/modern user interfaces without any modifications to the core source
  • Improve extensibility with a new plugin architecture

For lots more details, see the wiki!

What's been done so far

See the progress page for a comprehensive list.

Throughput Graph

What's being worked on now

  • Port all IO to libuv
  • Convert legacy tests to Lua tests
  • VimL => Lua translator

How do I get it?

There is a formula for OSX/homebrew, a PKGBUILD for Arch Linux, RPM, deb, and more. See the wiki!

Contributing

...would be awesome! See the wiki for more details.

License

Neovim is licensed under the terms of the Apache 2.0 license, except for parts that were contributed under the Vim license.

  • Contributions committed before b17d96 by authors who did not sign the Contributor License Agreement (CLA) remain under the Vim license.

  • Contributions committed after b17d96 are licensed under Apache 2.0 unless those contributions were copied from Vim (identified in the commit logs by the vim-patch token).

See LICENSE for details.

Vim is Charityware.  You can use and copy it as much as you like, but you are
encouraged to make a donation for needy children in Uganda.  Please see the
kcc section of the vim docs or visit the ICCF web site, available at these URLs:

        http://iccf-holland.org/
        http://www.vim.org/iccf/
        http://www.iccf.nl/

You can also sponsor the development of Vim.  Vim sponsors can vote for
features.  The money goes to Uganda anyway.