diff options
author | Tommy Allen <tommy@esdf.io> | 2018-11-07 04:31:25 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-11-07 10:31:25 +0100 |
commit | c4c74c3883aa3122c0c877ca8dd7b26beb5cc4aa (patch) | |
tree | 41eab89a4dda67634836178f4b374ab35630bb92 /src/nvim/os | |
parent | 769d164c70bee1877d101447ba41730147a2f127 (diff) | |
download | rneovim-c4c74c3883aa3122c0c877ca8dd7b26beb5cc4aa.tar.gz rneovim-c4c74c3883aa3122c0c877ca8dd7b26beb5cc4aa.tar.bz2 rneovim-c4c74c3883aa3122c0c877ca8dd7b26beb5cc4aa.zip |
jobstart(): Fix hang on non-executable cwd #9204
* os/fs.c: add os_isdir_executable()
* eval.c: fix hang on job start caused by non-executable cwd option
* channel.c: assert cwd is an executable directory
* test: jobstart() produces error when using non-executable cwd
Diffstat (limited to 'src/nvim/os')
-rw-r--r-- | src/nvim/os/fs.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index cf00fd4f82..9a4391a0ae 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -110,7 +110,7 @@ bool os_isrealdir(const char *name) /// Check if the given path is a directory or not. /// -/// @return `true` if `fname` is a directory. +/// @return `true` if `name` is a directory. bool os_isdir(const char_u *name) FUNC_ATTR_NONNULL_ALL { @@ -126,6 +126,25 @@ bool os_isdir(const char_u *name) return true; } +/// Check if the given path is a directory and is executable. +/// Gives the same results as `os_isdir()` on Windows. +/// +/// @return `true` if `name` is a directory and executable. +bool os_isdir_executable(const char *name) + FUNC_ATTR_NONNULL_ALL +{ + int32_t mode = os_getperm((const char *)name); + if (mode < 0) { + return false; + } + +#ifdef WIN32 + return (S_ISDIR(mode)); +#else + return (S_ISDIR(mode) && (S_IXUSR & mode)); +#endif +} + /// Check what `name` is: /// @return NODE_NORMAL: file or directory (or doesn't exist) /// NODE_WRITABLE: writable device, socket, fifo, etc. |