KCoreAddons

kprocesslist_unix_procstat.cpp
1/*
2
3 This file is part of the KDE Frameworks
4
5 SPDX-FileCopyrightText: 2019 Tobias C. Berner <tcberner@FreeBSD.org>
6
7 SPDX-License-Identifier: LGPL-2.1-only
8*/
9
10#include "kprocesslist.h"
11#include "kprocesslist_unix_procstat_p.h"
12
13#include <QDir>
14#include <QProcess>
15
16using namespace KProcessList;
17
18// Determine UNIX processes by using the procstat library
19KProcessInfoList KProcessList::processInfoList()
20{
22
23 ProcStat pstat;
24 if (!pstat) {
25 return rc;
26 }
27
28 ProcStatProcesses procs(pstat);
29 for (const auto &process_info : procs) {
30 rc.push_back(process_info);
31 }
32
33 return rc;
34}
35
36KProcessInfo KProcessList::processInfo(qint64 pid)
37{
38 KProcessInfoList processInfoList = KProcessList::processInfoList();
39 auto testProcessIterator = std::find_if(processInfoList.begin(), processInfoList.end(), [pid](const KProcessList::KProcessInfo &info) {
40 return info.pid() == pid;
41 });
42 return testProcessIterator != processInfoList.end() ? *testProcessIterator : KProcessInfo{};
43}
Contains information about a process.
iterator begin()
iterator end()
void push_back(parameter_type value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.