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
This commit is contained in:
Tommy Allen
2018-11-07 04:31:25 -05:00
committed by Justin M. Keyes
parent 769d164c70
commit c4c74c3883
4 changed files with 36 additions and 3 deletions

View File

@@ -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.