| 1 | #cxx . . $ `<file>/ProcessListLinux.cpp`/include "ProcessListLinux.h"cxx . . $ `<file>/ProcessListLinux.h`/ |
| 2 | #include <QDir> |
| 3 | #include <QFile> |
| 4 | #include <QTextStream> |
| 5 | #include <QDebug> |
| 6 | #include <QRegExp> |
| 7 | |
| 8 | ProcessListLinuxcxx . . $ ProcessListLinux#::ProcessListLinuxcxx . . $ ProcessListLinux#ProcessListLinux(49f6e7a06ebc5aa8).(){ |
| 9 | |
| 10 | } |
| 11 | |
| 12 | |
| 13 | int ProcessListLinuxcxx . . $ ProcessListLinux#::initProccessListcxx . . $ ProcessListLinux#initProccessList(b126dc7c1de90089).(){ |
| 14 | // Получение списка процессов |
| 15 | sProccesscxx . . $ sProccess# proc; |
| 16 | QMapcxx . . $ QMap#<QStringcxx . . $ QString#,sProccesscxx . . $ sProccess#> resultcxx . . $ QMap#QMap(ced63f7c635d850d).; |
| 17 | |
| 18 | QRegExpcxx . . $ QRegExp# rx_digitcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("^\\d+$"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 19 | |
| 20 | QDircxx . . $ QDir# dir = QDircxx . . $ QDir#QDir(3520e46b33348bf6).("/proc"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 21 | dir.setFiltercxx . . $ QDir#setFilter(3cb6a626764edf13).(QDircxx . . $ QFlags#QFlags(93d577a3e9528307).::AllDirscxx . . $ QDir#AllDirs.); |
| 22 | QFileInfoListcxx . . $ QFileInfoList# pidList = dir.entryInfoListcxx . . $ QDir#entryInfoList(c85cb969d00e05df).(); |
| 23 | for (int i=0;i<pidList.sizecxx . . $ QList#size(ea6fe5115c70a13f).();i++){ |
| 24 | QStringcxx . . $ QString# pid = pidList.atcxx . . $ QList#at(e2681f9bb6b2f357).(i).fileNamecxx . . $ QFileInfo#fileName(6ef7b6c27b00b43d).(); |
| 25 | if (!rx_digit.exactMatchcxx . . $ QRegExp#exactMatch(f3b39adf77d9c36c).(pid)) continue; |
| 26 | |
| 27 | |
| 28 | proc.pidcxx . . $ sProccess#pid.=cxx . . $ QString#`operator=`(b79fde0b0ce9b948).pid; |
| 29 | proc.socketscxx . . $ sProccess#sockets.=cxx . . $ QStringList#`operator=`(335bb966c1744308).getSocketscxx . . $ ProcessListLinux#getSockets(327870d3b2cb3fa6).(pidcxx . . $ QString#QString(132dd6869045752b).); |
| 30 | proc.programcxx . . $ sProccess#program.=cxx . . $ QString#`operator=`(4f35bf974e7f8568).getProgramcxx . . $ ProcessListLinux#getProgram(f7f320d754b8fd09).(pidcxx . . $ QString#QString(132dd6869045752b).); |
| 31 | proc.cmdlinecxx . . $ sProccess#cmdline.=cxx . . $ QString#`operator=`(4f35bf974e7f8568).getCmdlinecxx . . $ ProcessListLinux#getCmdline(f7f320d754b8fd09).(pidcxx . . $ QString#QString(132dd6869045752b).); |
| 32 | |
| 33 | result[cxx . . $ QMap#`operator[]`(bbd415b616967878).pid]=cxx . . $ sProccess#`operator=`(876f8a2c06aa7dd9).proc; |
| 34 | |
| 35 | } |
| 36 | |
| 37 | |
| 38 | proclistcxx . . $ ProcessListLinux#proclist.=cxx . . $ QMap#`operator=`(9a30e17cbbb0999d).result; |
| 39 | |
| 40 | return 1; |
| 41 | } |
| 42 | |
| 43 | |
| 44 | |
| 45 | sProccesscxx . . $ sProccess# ProcessListLinuxcxx . . $ ProcessListLinux#::getProccxx . . $ ProcessListLinux#getProc(a30611555c524a2e).(QStringcxx . . $ QString# inode){ |
| 46 | QMapIteratorcxx . . $ QMapIterator#<QStringcxx . . $ QString#, sProccesscxx . . $ sProccess#> icxx . . $ QMapIterator#QMapIterator(1d85e448f11cafa).(proclistcxx . . $ ProcessListLinux#proclist.); |
| 47 | while (i.hasNextcxx . . $ QMapIterator#hasNext(50ce9a9e25b4a850).()) { |
| 48 | i.nextcxx . . $ QMapIterator#next(5c754f5fbc3bb3d6).(); |
| 49 | for (int p=0;p<i.valuecxx . . $ QMapIterator#value(bdbd05d619d62250).().socketscxx . . $ sProccess#sockets..sizecxx . . $ QList#size(ea6fe5115c70a13f).();p++){ |
| 50 | if (i.valuecxx . . $ QMapIterator#value(bdbd05d619d62250).().socketscxx . . $ sProccess#sockets..atcxx . . $ QList#at(e2681f9bb6b2f357).(p)==cxx . . $ `operator==`(5bc2975d2d751687).inode){ |
| 51 | return i.valuecxx . . $ QMapIterator#value(bdbd05d619d62250).(); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | return sProccesscxx . . $ sProccess#(); |
| 57 | } |
| 58 | |
| 59 | |
| 60 | QStringcxx . . $ QString# ProcessListLinuxcxx . . $ ProcessListLinux#::getProgramcxx . . $ ProcessListLinux#getProgram(f7f320d754b8fd09).(QStringcxx . . $ QString# pid){ |
| 61 | QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).("/proc/"+cxx . . $ operator+(c75c3ae4eb9af1a8).pid+cxx . . $ operator+(3d22f08efddf8107)."/exe"); |
| 62 | return file.symLinkTargetcxx . . $ QFile#symLinkTarget(6ef7b6c27b00b43d).(); |
| 63 | } |
| 64 | |
| 65 | QStringcxx . . $ QString# ProcessListLinuxcxx . . $ ProcessListLinux#::getCmdlinecxx . . $ ProcessListLinux#getCmdline(f7f320d754b8fd09).(QStringcxx . . $ QString# pid){ |
| 66 | QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).("/proc/"+cxx . . $ operator+(c75c3ae4eb9af1a8).pid+cxx . . $ operator+(3d22f08efddf8107)."/cmdline"); |
| 67 | if (!file.opencxx . . $ QFile#open(dca164408be960c8).(QIODevicecxx . . $ QIODevice#::ReadOnlycxx . . $ QIODevice#ReadOnly. |cxx . . $ `operator|`(c9e45f682471e48d). QIODevicecxx . . $ QIODevice#::Textcxx . . $ QIODevice#Text.)) return ""cxx . . $ QString#QString(85c52e162fed56f9).; |
| 68 | QTextStreamcxx . . $ QTextStream# incxx . . $ QTextStream#QTextStream(bebe8f2dee7f9e86).(&file); |
| 69 | QStringcxx . . $ QString# result = in.readAllcxx . . $ QTextStream#readAll(4365c3963150523e).(); |
| 70 | file.closecxx . . $ QFileDevice#close(49f6e7a06ebc5aa8).(); |
| 71 | |
| 72 | for (int i=0;i<result.sizecxx . . $ QString#size(455f465bc33b4cdf).();i++){ |
| 73 | if (result[cxx . . $ QString#`operator[]`(57436120916eb52c).i].unicodecxx . . $ QCharRef#unicode(39aa489f131cef24).()==0){ |
| 74 | result=cxx . . $ QString#`operator=`(b79fde0b0ce9b948).result.midcxx . . $ QString#mid(44b7563da18aea72).(0,i)+cxx . . $ operator+(3d22f08efddf8107)." "+cxx . . $ operator+(fab9b4f80031f353).result.midcxx . . $ QString#mid(44b7563da18aea72).(i+1); |
| 75 | } |
| 76 | |
| 77 | } |
| 78 | |
| 79 | return resultcxx . . $ QString#QString(28715ad661ad3cec).; |
| 80 | } |
| 81 | |
| 82 | QStringListcxx . . $ QStringList# ProcessListLinuxcxx . . $ ProcessListLinux#::getSocketscxx . . $ ProcessListLinux#getSockets(327870d3b2cb3fa6).(QStringcxx . . $ QString# pid){ |
| 83 | QStringListcxx . . $ QStringList# resultcxx . . $ QStringList#QStringList(ced63f7c635d850d).; |
| 84 | |
| 85 | QRegExpcxx . . $ QRegExp# rxcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("(.*)socket:\\[(.*)\\]"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 86 | |
| 87 | QDircxx . . $ QDir# dir = QDircxx . . $ QDir#QDir(3520e46b33348bf6).("/proc/"+cxx . . $ operator+(c75c3ae4eb9af1a8).pid+cxx . . $ operator+(3d22f08efddf8107)."/fd/"); |
| 88 | dir.setFiltercxx . . $ QDir#setFilter(3cb6a626764edf13).(QDircxx . . $ QFlags#QFlags(93d577a3e9528307).::AllDirscxx . . $ QDir#AllDirs.); |
| 89 | QFileInfoListcxx . . $ QFileInfoList# fdList = dir.entryInfoListcxx . . $ QDir#entryInfoList(c85cb969d00e05df).(); |
| 90 | for (int i=0;i<fdList.sizecxx . . $ QList#size(ea6fe5115c70a13f).();i++){ |
| 91 | QStringcxx . . $ QString# link = fdList.atcxx . . $ QList#at(e2681f9bb6b2f357).(i).symLinkTargetcxx . . $ QFileInfo#symLinkTarget(6ef7b6c27b00b43d).(); |
| 92 | if (rx.exactMatchcxx . . $ QRegExp#exactMatch(f3b39adf77d9c36c).(link)){ |
| 93 | result.appendcxx . . $ QList#append(77d9f17553126ecb).(rx.capcxx . . $ QRegExp#cap(ce915ed341d4a7f0).(2)); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | return result; |
| 98 | } |