--- src/utils/serviceutils.h.orig 2024-08-05 16:52:34 UTC +++ src/utils/serviceutils.h @@ -9,6 +9,10 @@ #pragma once +#if defined(__FreeBSD__) +#include +#include +#endif // cmake stuff #include "config-kwin.h" // kwin @@ -19,7 +23,6 @@ #include // KF #include - namespace KWin { @@ -66,8 +69,17 @@ static inline QStringList fetchRestrictedDBusInterface static inline QStringList fetchRestrictedDBusInterfacesFromPid(const uint pid) { +#ifdef __FreeBSD__ +static int pathname[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; + pathname[3] = pid; + size_t path_size = PATH_MAX; + char *executablePath =(char*)malloc( path_size ); + sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), executablePath, &path_size, NULL, 0 ); +#else const auto executablePath = QFileInfo(QStringLiteral("/proc/%1/exe").arg(pid)).symLinkTarget(); +#endif return fetchProcessServiceField(executablePath, s_dbusRestrictedInterfaceName); + } } // namespace