Skip to content

Commit

Permalink
posix_spawn: handle executable being a directory
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Jan 24, 2024
1 parent 5cf76df commit 93d4414
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion process.c
Original file line number Diff line number Diff line change
Expand Up @@ -4759,7 +4759,16 @@ rb_posix_spawn(struct rb_execarg *eargp)
// posix_spawn only returns fork/vfork/clone failures.
// If it failed but errno == 0, then it must be an "exec" failure.
if (errno == 0) {
eaccess(abspath, X_OK);
if (!eaccess(abspath, X_OK)) {
// abspath is executable
struct stat file_stat;
if (stat(abspath, &file_stat)) {
rb_sys_fail(abspath);
}
if (S_ISDIR(file_stat.st_mode)) {
errno = EISDIR;
}
}
}
rb_sys_fail(abspath);
}
Expand Down

0 comments on commit 93d4414

Please sign in to comment.