int execvpe(constchar* name, char* const* argv, char* const* envp) { // Do not allow null name. if (name == nullptr || *name == '\0') {
errno = ENOENT; return -1;
}
// If it's an absolute or relative path name, it's easy. if (strchr(name, '/') && execve(name, argv, envp) == -1) { if (errno == ENOEXEC) return __exec_as_script(name, argv, envp); return -1;
}
// Get the path we're searching. constchar* path = getenv("PATH"); if (path == nullptr) path = _PATH_DEFPATH;
// Make a writable copy.
size_t len = strlen(path) + 1; char writable_path[len];
memcpy(writable_path, path, len);
bool saw_EACCES = false;
// Try each element of $PATH in turn... char* strsep_buf = writable_path; constchar* dir; while ((dir = strsep(&strsep_buf, ":"))) { // It's a shell path: double, leading and trailing colons // mean the current directory. if (*dir == '\0') dir = const_cast<char*>(".");
execve(buf, argv, envp); switch (errno) { case EISDIR: case ELOOP: case ENAMETOOLONG: case ENOENT: case ENOTDIR: break; case ENOEXEC: return __exec_as_script(buf, argv, envp); case EACCES:
saw_EACCES = true; break; default: return -1;
}
} if (saw_EACCES) errno = EACCES; return -1;
}
int fexecve(int fd, char* const* argv, char* const* envp) { // execveat with AT_EMPTY_PATH (>= 3.19) seems to offer no advantages.
execve(FdPath(fd).c_str(), argv, envp); if (errno == ENOENT) errno = EBADF; return -1;
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.0Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.