linrrzqqq commented on code in PR #67312:
URL: https://github.com/apache/doris/pull/67312#discussion_r3887289354


##########
be/src/glibc-compatibility/musl/execvpe.c:
##########
@@ -0,0 +1,55 @@
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static char* strchrnul_compat(const char* str, int ch) {
+    const char* found = strchr(str, ch);
+    return (char*)(found ? found : str + strlen(str));
+}
+
+int __execvpe(const char* file, char* const argv[], char* const envp[]) {
+    const char* path = getenv("PATH");
+    int seen_eacces = 0;
+
+    errno = ENOENT;
+    if (!*file) return -1;
+    if (strchr(file, '/')) return execve(file, argv, envp);
+    if (!path) path = "/usr/local/bin:/bin:/usr/bin";
+
+    size_t file_len = strnlen(file, NAME_MAX + 1);
+    if (file_len > NAME_MAX) {
+        errno = ENAMETOOLONG;
+        return -1;
+    }
+    size_t path_len = strnlen(path, PATH_MAX - 1) + 1;
+
+    const char* cursor;
+    const char* end;
+    for (cursor = path;; cursor = end) {
+        char candidate[path_len + file_len + 1];

Review Comment:
   fork from 
https://github.com/amosbird/ldb_toolchain_gen/blob/v0.27/glibc-compatibility/glibc-compatibility.c#L187-L427



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to