Skip to content

Commit 0e09ba3

Browse files
committedJan 22, 2024
posix_spawn: handle executable being a directory
1 parent 1f0c181 commit 0e09ba3

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
@@ -4757,7 +4757,16 @@ rb_posix_spawn(struct rb_execarg *eargp)
47574757
// posix_spawn only returns fork/vfork/clone failures.
47584758
// If it failed but errno == 0, then it must be an "exec" failure.
47594759
if (errno == 0) {
4760-
eaccess(abspath, X_OK);
4760+
if (!eaccess(abspath, X_OK)) {
4761+
// abspath is executable
4762+
struct stat file_stat;
4763+
if (stat(abspath, &file_stat)) {
4764+
rb_sys_fail(abspath);
4765+
}
4766+
if (S_ISDIR(file_stat.st_mode)) {
4767+
errno = EISDIR;
4768+
}
4769+
}
47614770
}
47624771
rb_sys_fail(abspath);
47634772
}

0 commit comments

Comments
 (0)
Failed to load comments.