Skip to content

Commit

Permalink
disable process functions on iOS (#1173)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Nov 7, 2024
1 parent c927bcd commit 5e52ade
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/lib/fcitx-utils/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@
#include <sys/user.h>
#endif
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#if TARGET_OS_OSX
#include <libproc.h>
#endif
#endif

namespace fcitx {

void startProcess(const std::vector<std::string> &args,
const std::string &workingDirectory) {
#if defined(__APPLE__) && TARGET_OS_IPHONE
FCITX_UNUSED(args);
FCITX_UNUSED(workingDirectory);
FCITX_ERROR() << "Not implemented";
return;
#else
/* exec command */
pid_t child_pid;

Expand Down Expand Up @@ -67,6 +76,7 @@ void startProcess(const std::vector<std::string> &args,
int status;
waitpid(child_pid, &status, 0);
}
#endif
}

std::string getProcessName(pid_t pid) {
Expand Down Expand Up @@ -111,13 +121,19 @@ std::string getProcessName(pid_t pid) {
kvm_close(vm);
return result;
#elif defined(__APPLE__)
#if TARGET_OS_IPHONE
FCITX_UNUSED(pid);
FCITX_ERROR() << "Not implemented";
return "";
#else
std::string result;
result.reserve(2 * MAXCOMLEN);

if (proc_name(pid, result.data(), 2 * MAXCOMLEN)) {
return {};
}
return result;
#endif
#else
auto path = fmt::format("/proc/{}/exe", pid);
if (auto link = fs::readlink(path)) {
Expand All @@ -135,13 +151,17 @@ ssize_t getline(UniqueCPtr<char> &lineptr, size_t *n, std::FILE *stream) {
}

bool isInFlatpak() {
#ifdef __APPLE__
return false;
#else
static const bool flatpak = []() {
if (checkBoolEnvVar("FCITX_OVERRIDE_FLATPAK")) {
return true;
}
return fs::isreg("/.flatpak-info");
}();
return flatpak;
#endif
}

} // namespace fcitx

0 comments on commit 5e52ade

Please sign in to comment.