Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable process functions on iOS #1173

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading