KCoreAddons

kprocesslist.h
1/*
2 This file is part of the KDE Frameworks
3
4 SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
5 SPDX-FileCopyrightText: 2019 David Hallas <david@davidhallas.dk>
6
7 SPDX-License-Identifier: LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR LicenseRef-Qt-Commercial
8*/
9
10#ifndef KPROCESSLIST_H
11#define KPROCESSLIST_H
12
13#include <QList>
14#include <QSharedDataPointer>
15#include <QString>
16#include <kcoreaddons_export.h>
17
18namespace KProcessList
19{
20class KProcessInfoPrivate;
21
22/**
23 * @brief Contains information about a process. This class is usually not used alone but rather returned by
24 * processInfoList and processInfo. To check if the data contained in this class is valid use the isValid method.
25 * @since 5.58
26 */
27class KCOREADDONS_EXPORT KProcessInfo
28{
29public:
31 KProcessInfo(qint64 pid, const QString &command, const QString &user);
32 KProcessInfo(qint64 pid, const QString &command, const QString &name, const QString &user);
33
34 KProcessInfo(const KProcessInfo &other);
36 KProcessInfo &operator=(const KProcessInfo &other);
37 /**
38 * @brief If the KProcessInfo contains valid information. If it returns true the pid, name and user function
39 * returns valid information, otherwise they return value is undefined.
40 */
41 bool isValid() const;
42 /**
43 * @brief The pid of the process
44 */
45 qint64 pid() const;
46 /**
47 * @brief The name of the process. The class will try to get the full path to the executable file for the process
48 * but if it is not available the name of the process will be used instead.
49 * e.g /bin/ls
50 */
51 QString name() const;
52 /**
53 * @brief The username the process is running under.
54 */
55 QString user() const;
56 /**
57 * @brief The command line running this process
58 * e.g /bin/ls /some/path -R
59 * @since 5.61
60 */
61 QString command() const;
62
63private:
65};
66
68
69/**
70 * @brief Retrieves the list of currently active processes.
71 * @since 5.58
72 */
73KCOREADDONS_EXPORT KProcessInfoList processInfoList();
74
75/**
76 * @brief Retrieves process information for a specific process-id. If the process is not found a KProcessInfo with
77 * isValid == false will be returned.
78 * @param pid The process-id to retrieve information for.
79 * @since 5.58
80 */
81KCOREADDONS_EXPORT KProcessInfo processInfo(qint64 pid);
82
83} // KProcessList namespace
84
85Q_DECLARE_TYPEINFO(KProcessList::KProcessInfo, Q_RELOCATABLE_TYPE);
86
87#endif // KPROCESSLIST_H
Contains information about a process.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.