/usr/include/ksysguard/processes.h is in kde-workspace-dev 4:4.11.8-0ubuntu6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | /* This file is part of the KDE project
Copyright (C) 2007 John Tapsell <tapsell@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef PROCESSES_H_
#define PROCESSES_H_
#include <kdemacros.h>
#include "process.h"
#include <QtCore/QHash>
namespace KSysGuard
{
class AbstractProcesses;
/**
* This class retrieves the processes currently running in an OS independent way.
*
* To use, do something like:
*
* \code
* #include <ksysguard/processes.h>
* #include <ksysguard/process.h>
*
* KSysGuard::Processes *processes = new KSysGuard::Processes()
* QHash<long, Process *> processlist = processes->getProcesses();
* foreach( Process * process, processlist) {
* kDebug() << "Process with pid " << process->pid << " is called " << process->name;
* }
* delete processes;
* processes = NULL;
* \endcode
*
* @author John Tapsell <tapsell@kde.org>
*/
#ifdef Q_WS_WIN
class Processes : public QObject
#else
class KDE_EXPORT Processes : public QObject
#endif
{
Q_OBJECT
public:
Processes(const QString &hostname = QString::null, QObject * parent = 0);
virtual ~Processes();
enum UpdateFlag {
StandardInformation = 1,
IOStatistics = 2,
XMemory = 4
};
Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag)
enum Error {
Unknown = 0,
InvalidPid,
InvalidParameter,
InsufficientPermissions,
ProcessDoesNotExistOrZombie,
NotSupported
};
/**
* Update all the process information. After calling this, /proc or equivalent is scanned and
* the signals processChanged, etc are emitted.
*
* Set updateDuration to whatever time period that you update, in milliseconds.
* For example, if you update every 2000ms, set this to 2000. That way it won't update
* more often than needed.
*/
void updateAllProcesses(long updateDurationMS = 0, Processes::UpdateFlags updateFlags = 0);
/**
* Return information for one specific process. Call getProcess(0) to get the
* fake process used as the top most parent for all processes.
* This doesn't fetch any new information and so returns almost instantly.
* Call updateAllProcesses() to actually fetch the process information.
*/
Process *getProcess(long pid) const;
/**
* Get the error code for the last command that failed.
*/
Error lastError() const;
/**
* Kill the specified process. You may not have the privilege to kill the process.
* The process may also chose to ignore the command. Send the SIGKILL signal to kill
* the process immediately. You may lose any unsaved data.
*
* @returns Successful or not in killing the process
*/
bool killProcess(long pid);
/**
* Send the specified named POSIX signal to the process given.
*
* For example, to indicate for process 324 to STOP do:
* \code
* #include <signals.h>
* ...
*
* KSysGuard::Processes::sendSignal(23, SIGSTOP);
* \endcode
*
*/
bool sendSignal(long pid, int sig);
/**
* Set the priority for a process. This is from 19 (very nice, lowest priority) to
* -20 (highest priority). The default value for a process is 0.
*
* @return false if you do not have permission to set the priority
*/
bool setNiceness(long pid, int priority);
/**
* Set the scheduler for a process. This is defined according to POSIX.1-2001
* See "man sched_setscheduler" for more information.
*
* @p priorityClass One of SCHED_FIFO, SCHED_RR, SCHED_OTHER, and SCHED_BATCH
* @p priority Set to 0 for SCHED_OTHER and SCHED_BATCH. Between 1 and 99 for SCHED_FIFO and SCHED_RR
* @return false if you do not have permission to set the priority
*/
bool setScheduler(long pid, KSysGuard::Process::Scheduler priorityClass, int priority);
/**
* Set the io priority for a process. This is from 7 (very nice, lowest io priority) to
* 0 (highest priority). The default value is determined as: io_nice = (cpu_nice + 20) / 5.
*
* @return false if you do not have permission to set the priority
*/
bool setIoNiceness(long pid, KSysGuard::Process::IoPriorityClass priorityClass, int priority);
/**
* Returns true if ionice is supported on this system
*/
bool supportsIoNiceness();
/**
* Return the internal pointer of all the processes. The order of the processes
* is guaranteed to never change. Call updateAllProcesses() first to actually
* update the information.
*/
const QList< Process *> &getAllProcesses() const;
/**
* Return the number of processes. Call updateAllProcesses() to actually
* update the information.
*
* This is equivalent to getAllProcesses().count()
*/
int processCount() const;
/**
* Return the total amount of physical memory in KB. This is fast (just a system call)
* Returns 0 on error
*/
long long totalPhysicalMemory();
/**
* Return the number of processor cores enabled.
* (A system can disable processors. Disabled processors are not counted here).
* This is fast (just a system call) */
long numberProcessorCores();
/** Update/add process for given pid immediately */
bool updateOrAddProcess( long pid);
/** Whether we can get historic process and system data */
bool isHistoryAvailable() const;
/** Stop using historical data and use the most recent up-to-date data */
void useCurrentData();
/** Return a list of end times and intervals for all the available history */
QList< QPair<QDateTime, uint> > historiesAvailable() const;
/** Use historical process data closest to the given date-time.
* Returns false if it is outside the range available or there is a problem
* getting the data. */
bool setViewingTime(const QDateTime &when);
QDateTime viewingTime() const;
bool loadHistoryFile(const QString &filename);
QString historyFileName() const;
public Q_SLOTS:
/** The abstract processes has updated its list of processes */
void processesUpdated();
Q_SIGNALS:
/** The data for a process has changed.
* if @p onlyTotalCpu is set, only the total cpu usage has been updated.
* process->changes contains a bit field indicating what has changed since the last time this was emitted
* for this process
*/
void processChanged( KSysGuard::Process *process, bool onlyTotalCpu);
/**
* This indicates we are about to add a process in the model.
* The process already has the pid, ppid and tree_parent set up.
*/
void beginAddProcess( KSysGuard::Process *process);
/**
* We have finished inserting a process
*/
void endAddProcess();
/**
* This indicates we are about to remove a process in the model. Emit the appropriate signals
*/
void beginRemoveProcess( KSysGuard::Process *process);
/**
* We have finished removing a process
*/
void endRemoveProcess();
/**
* This indicates we are about move a process from one parent to another.
*/
void beginMoveProcess(KSysGuard::Process *process, KSysGuard::Process *new_parent);
/**
* We have finished moving the process
*/
void endMoveProcess();
protected:
class Private;
Private *d;
private:
inline void deleteProcess(long pid);
bool updateProcess( Process *process, long ppid);
bool updateProcessInfo(Process *ps);
bool addProcess(long pid, long ppid);
Q_SIGNALS:
/** For a remote machine, we rely on being able to communicate with ksysguardd.
* This must be dealt with by the program including this widget. It must listen to our
* 'runCommand' signal, and run the given command, with the given id. */
void runCommand(const QString &command, int id);
public:
/** For a remote machine, we rely on being able to communicate with ksysguardd.
* The programming using this must call this slot when an answer is received from ksysguardd,
* in response to a runCommand request. The id identifies the answer */
void answerReceived( int id, const QList<QByteArray>& answer );
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Processes::UpdateFlags)
}
#endif
|