mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-08 10:50:28 +00:00
sysv execve zipos fix APE if APE loader is installed
This commit is contained in:
parent
385dca4ec0
commit
20b75864e6
1 changed files with 7 additions and 7 deletions
|
@ -85,6 +85,13 @@ int sys_execve(const char *prog, char *const argv[], char *const envp[]) {
|
|||
newprog = alloca(PATH_MAX);
|
||||
fd = _weaken(__zipos_uri_to_mem_file)(&uri, newprog);
|
||||
prog = newprog;
|
||||
if ((fd != -1) && IsApeBinary(prog)) {
|
||||
flags = fcntl(fd, F_GETFD);
|
||||
if (flags != -1) {
|
||||
fcntl(fd, F_SETFD, flags & (~FD_CLOEXEC));
|
||||
flags = fcntl(fd, F_GETFD);
|
||||
}
|
||||
}
|
||||
} else if (IsFreebsd()) {
|
||||
if ((fd = _weaken(__zipos_uri_to_mem_file)(&uri, NULL)) != -1) {
|
||||
return sys_fexecve(fd, argv, envp);
|
||||
|
@ -104,13 +111,6 @@ int sys_execve(const char *prog, char *const argv[], char *const envp[]) {
|
|||
for (i = 0; argv[i];) ++i;
|
||||
buf = alloca(PATH_MAX);
|
||||
shargs = alloca((i + 4) * sizeof(char *));
|
||||
if (fd != -1) {
|
||||
flags = fcntl(fd, F_GETFD);
|
||||
if (flags != -1) {
|
||||
fcntl(fd, F_SETFD, flags & (~FD_CLOEXEC));
|
||||
flags = fcntl(fd, F_GETFD);
|
||||
}
|
||||
}
|
||||
if (IsApeBinary(prog) &&
|
||||
(CanExecute((ape = "/usr/bin/ape")) ||
|
||||
CanExecute((ape = Join(firstnonnull(getenv("TMPDIR"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue