process list modified
This commit is contained in:
parent
ce74d1237b
commit
cd19462002
1 changed files with 43 additions and 0 deletions
|
|
@ -429,6 +429,45 @@ Future<List<ProcessInfo>> findProcess(String searchWord,
|
|||
? await ProcessSilentExecutor.runSlientBat(shell)
|
||||
: await runGetStdout(shell);
|
||||
pList = parseProcessStd(stdout);
|
||||
} else if (Platform.isLinux) {
|
||||
var shell = StringBuffer('ps -ef | grep \'$searchWord\' | grep -v grep');
|
||||
var result = await ProcessExecutor.run(shell, printStdout: false);
|
||||
if (result.exitCode == 0) {
|
||||
var procList = result.stdout.toString().split('\n');
|
||||
for (var proc in procList) {
|
||||
if (proc.isNotEmpty) {
|
||||
var info = ProcessInfo();
|
||||
var index = proc.indexOf(' ');
|
||||
//deck 61218 920 0 08:24 ? 00:00:11 /home/deck/SDK/flutter/bin/cache/dart-sdk/bin/dart /home/deck/work/oto_cli/bin/main.dart scheduler -s
|
||||
proc = proc.substring(index, proc.length).trimLeft();
|
||||
index = proc.indexOf(' ');
|
||||
info.pid = int.parse(proc.substring(0, index));
|
||||
proc = proc.substring(index).trimLeft();
|
||||
|
||||
index = proc.indexOf(' ');
|
||||
info.ppid = int.parse(proc.substring(0, index));
|
||||
proc = proc.substring(index).trimLeft();
|
||||
|
||||
index = proc.indexOf(' ');
|
||||
info.cpuUsage = int.parse(proc.substring(0, index));
|
||||
proc = proc.substring(index).trimLeft();
|
||||
|
||||
index = proc.indexOf(' ');
|
||||
info.startTime = proc.substring(0, index);
|
||||
proc = proc.substring(index).trimLeft();
|
||||
|
||||
index = proc.indexOf(' ');
|
||||
info.sessionName = proc.substring(0, index);
|
||||
proc = proc.substring(index).trimLeft();
|
||||
|
||||
index = proc.indexOf(' ');
|
||||
info.duration = proc.substring(0, index);
|
||||
|
||||
info.name = proc.substring(index).trimLeft();
|
||||
pList.add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var shell = StringBuffer(
|
||||
'ps -A | grep \'$searchWord\' | grep -v grep | awk \'{\$2=\$3=""; print \$0}\'');
|
||||
|
|
@ -628,6 +667,10 @@ class ProcessInfoListener {
|
|||
}
|
||||
|
||||
class ProcessInfo {
|
||||
String? startTime;
|
||||
String? duration;
|
||||
int? ppid;
|
||||
int? cpuUsage;
|
||||
late String name;
|
||||
late int pid;
|
||||
late String sessionName;
|
||||
|
|
|
|||
Loading…
Reference in a new issue