Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use posix spawn #551

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Prev Previous commit
posix_spawn: handle executable being a directory
  • Loading branch information
byroot committed Jan 24, 2024
commit bba8ef3cc0381870c0472f5fb9762e546a15c6ee
11 changes: 10 additions & 1 deletion process.c
Original file line number Diff line number Diff line change
@@ -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);
}
Loading
Oops, something went wrong.