Index: lib/Fuzzer/FuzzerIO.cpp =================================================================== --- lib/Fuzzer/FuzzerIO.cpp +++ lib/Fuzzer/FuzzerIO.cpp @@ -92,7 +92,12 @@ } void PrintFileAsBase64(const std::string &Path) { - std::string Cmd = "base64 -w 0 < " + Path + "; echo"; +#ifdef __APPLE__ + std::string Cmd = "base64"; +#else + std::string Cmd = "base64 -w 0"; +#endif + Cmd += " < " + Path + "; echo"; ExecuteCommand(Cmd); } Index: lib/Fuzzer/FuzzerUtil.cpp =================================================================== --- lib/Fuzzer/FuzzerUtil.cpp +++ lib/Fuzzer/FuzzerUtil.cpp @@ -62,7 +62,12 @@ } int NumberOfCpuCores() { - FILE *F = popen("nproc", "r"); +#ifdef __APPLE__ + const char *command = "sysctl -n hw.ncpu"; +#else + const char *command = "nproc"; +#endif + FILE *F = popen(command, "r"); int N = 0; fscanf(F, "%d", &N); fclose(F); @@ -70,7 +75,22 @@ } int ExecuteCommand(const std::string &Command) { +#ifdef __APPLE__ + pid_t pid = fork(); + int status = 0; + if (pid == -1) + _exit(EXIT_FAILURE); // exec never returns + else if (pid > 0) + waitpid(pid, &status, 0); + else { + // we are the child + execl("/bin/bash", "/bin/bash", "-c", Command.c_str(), nullptr); + _exit(EXIT_FAILURE); // exec never returns + } + return status; +#else return system(Command.c_str()); +#endif } bool ToASCII(Unit &U) {