| 47 | } |
| 48 | |
| 49 | void ProcessTrackerBackendLinux::checkProcess(qint64 pid) |
| 50 | { |
| 51 | GammaRay::ProcessTrackerInfo pinfo(pid); |
| 52 | QString buffer(readFile(QString::fromLatin1("/proc/%1/status").arg(pid))); |
| 53 | |
| 54 | if (!buffer.isEmpty()) { |
| 55 | const QStringList values = buffer.remove(QLatin1Char('\t')).split(QLatin1Char('\n')); |
| 56 | |
| 57 | for (const QString &value : values) { |
| 58 | if (value.startsWith(QStringLiteral("TracerPid:"))) { |
| 59 | pinfo.traced = value.split(QLatin1Char(':')).value(1).simplified().toLongLong(); |
| 60 | } else if (value.startsWith(QStringLiteral("State:"))) { |
| 61 | const char status(value.split(QLatin1Char(':')).value(1).simplified()[0].toUpper().toLatin1()); |
| 62 | |
| 63 | // status decoding as taken from fs/proc/array.c |
| 64 | switch (status) { |
| 65 | case 'T': { |
| 66 | pinfo.state = GammaRay::ProcessTracker::Suspended; |
| 67 | break; |
| 68 | } |
| 69 | |
| 70 | case 'S': // Sleeping |
| 71 | case 'R': { |
| 72 | pinfo.state = GammaRay::ProcessTracker::Running; |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | // case 'Z': // Zombie |
| 77 | // case 'D': // Disk Sleep |
| 78 | // case 'W': // Paging |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | emit processChecked(pinfo); |
| 85 | } |