summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/base/utils.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-02-21 20:02:48 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-02-21 20:02:48 +0100
commitcfae625a73029218f6df4460606a55c101544cd5 (patch)
tree65bd5c4057a96a74db0a5ce7ed630fba7d3ea145 /rbutil/rbutilqt/base/utils.cpp
parentd5bd4ec6820db58c2989fc7ecc5297c770515e83 (diff)
downloadrockbox-cfae625a73029218f6df4460606a55c101544cd5.tar.gz
rockbox-cfae625a73029218f6df4460606a55c101544cd5.tar.bz2
rockbox-cfae625a73029218f6df4460606a55c101544cd5.zip
Implement findProcess() on OS X.
Change-Id: Iec5e91f1c8c08a58a19f79339d03247148347d45
Diffstat (limited to 'rbutil/rbutilqt/base/utils.cpp')
-rw-r--r--rbutil/rbutilqt/base/utils.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp
index 28162a93f3..5c80e1225c 100644
--- a/rbutil/rbutilqt/base/utils.cpp
+++ b/rbutil/rbutilqt/base/utils.cpp
@@ -54,6 +54,7 @@
#include <tlhelp32.h>
#endif
#if defined(Q_OS_MACX)
+#include <Carbon/Carbon.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <IOKit/IOKitLib.h>
@@ -643,10 +644,36 @@ QStringList Utils::findRunningProcess(QStringList names)
}
} while(result);
CloseHandle(hdl);
- qDebug() << processlist;
#endif
#if defined(Q_OS_MACX)
+ ProcessSerialNumber psn = { 0, kNoProcess };
+ OSErr err;
+ do {
+ pid_t pid;
+ err = GetNextProcess(&psn);
+ err = GetProcessPID(&psn, &pid);
+ if(err == noErr) {
+ char buf[32] = {0};
+ ProcessInfoRec info;
+ memset(&info, 0, sizeof(ProcessInfoRec));
+ info.processName = (unsigned char*)buf;
+ info.processInfoLength = sizeof(ProcessInfoRec);
+ err = GetProcessInformation(&psn, &info);
+ if(err == noErr) {
+ // some processes start with nonprintable characters. Skip those.
+ int i;
+ for(i = 0; i < 32; i++) {
+ if(isprint(buf[i])) break;
+ }
+ // avoid adding duplicates.
+ QString process = QString::fromUtf8(&buf[i]);
+ if(!processlist.contains(process)) {
+ processlist.append(process);
+ }
+ }
+ }
+ } while(err == noErr);
#endif
// check for given names in list of processes
for(int i = 0; i < names.size(); ++i) {