Skip to content

Commit 93d4414

Browse files
committedJan 24, 2024
posix_spawn: handle executable being a directory
1 parent 5cf76df commit 93d4414

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎process.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -4759,7 +4759,16 @@ rb_posix_spawn(struct rb_execarg *eargp)
47594759
// posix_spawn only returns fork/vfork/clone failures.
47604760
// If it failed but errno == 0, then it must be an "exec" failure.
47614761
if (errno == 0) {
4762-
eaccess(abspath, X_OK);
4762+
if (!eaccess(abspath, X_OK)) {
4763+
// abspath is executable
4764+
struct stat file_stat;
4765+
if (stat(abspath, &file_stat)) {
4766+
rb_sys_fail(abspath);
4767+
}
4768+
if (S_ISDIR(file_stat.st_mode)) {
4769+
errno = EISDIR;
4770+
}
4771+
}
47634772
}
47644773
rb_sys_fail(abspath);
47654774
}

0 commit comments

Comments
 (0)
Failed to load comments.