From 4d58a4ea8daf1a3cb91b7d8c6e574dd6f5bdb685 Mon Sep 17 00:00:00 2001 From: Denis Kozadaev Date: Thu, 18 May 2023 21:41:25 +0300 Subject: SunOS specific patches Signed-off-by: Denis Kozadaev --- kicker/applets/naughty/NaughtyProcessMonitor.cpp | 31 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'kicker/applets/naughty') diff --git a/kicker/applets/naughty/NaughtyProcessMonitor.cpp b/kicker/applets/naughty/NaughtyProcessMonitor.cpp index 09c02cbf9..0239720fe 100644 --- a/kicker/applets/naughty/NaughtyProcessMonitor.cpp +++ b/kicker/applets/naughty/NaughtyProcessMonitor.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef Q_OS_SOLARIS +#include +#endif + #include #include #include @@ -210,7 +214,7 @@ NaughtyProcessMonitor::_process(ulong pid, uint load) bool NaughtyProcessMonitor::canKill(ulong pid) const { -#ifdef __linux__ +#ifdef Q_OS_LINUX TQFile f("/proc/" + TQString::number(pid) + "/status"); if (!f.open(IO_ReadOnly)) @@ -240,6 +244,17 @@ NaughtyProcessMonitor::canKill(ulong pid) const return false ; return geteuid () == d->uidMap_[pid] ; +#elif defined(Q_OS_SOLARIS) + TQFile f("/proc/" + TQString::number(pid) + "/psinfo"); + TQByteArray raw; + psinfo_t *inf; + + if (!f.open(IO_ReadOnly)) + return false; + raw = f.readAll(); + f.close(); + inf = (psinfo_t *)raw.data(); + return geteuid() == inf->pr_euid; #else Q_UNUSED( pid ); return false; @@ -249,8 +264,9 @@ NaughtyProcessMonitor::canKill(ulong pid) const TQString NaughtyProcessMonitor::processName(ulong pid) const { -#if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) -#ifdef __linux__ +#if defined(Q_OS_LINUX) || defined(__OpenBSD__) || defined(__NetBSD__) || \ + defined(Q_OS_SOLARIS) +#if defined(Q_OS_LINUX) || defined(Q_OS_SOLARIS) TQFile f("/proc/" + TQString::number(pid) + "/cmdline"); if (!f.open(IO_ReadOnly)) @@ -344,7 +360,7 @@ NaughtyProcessMonitor::processName(ulong pid) const uint NaughtyProcessMonitor::cpuLoad() const { -#ifdef __linux__ +#ifdef Q_OS_LINUX TQFile f("/proc/stat"); if (!f.open(IO_ReadOnly)) @@ -400,7 +416,7 @@ NaughtyProcessMonitor::cpuLoad() const TQValueList NaughtyProcessMonitor::pidList() const { -#ifdef __linux__ +#if defined(Q_OS_LINUX) || defined(Q_OS_SOLARIS) TQStringList dl(TQDir("/proc").entryList()); TQValueList pl; @@ -505,7 +521,7 @@ NaughtyProcessMonitor::pidList() const bool NaughtyProcessMonitor::getLoad(ulong pid, uint & load) const { -#ifdef __linux__ +#ifdef Q_OS_LINUX TQFile f("/proc/" + TQString::number(pid) + "/stat"); if (!f.open(IO_ReadOnly)) @@ -540,7 +556,8 @@ NaughtyProcessMonitor::getLoad(ulong pid, uint & load) const bool NaughtyProcessMonitor::kill(ulong pid) const { -#if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) +#if defined(Q_OS_LINUX) || defined(__OpenBSD__) || defined(__NetBSD__) ||\ + defined(Q_OS_SOLARIS) return 0 == ::kill(pid, SIGKILL); #else Q_UNUSED( pid ); -- cgit v1.2.1