2014-11-27 21:02:52 -02:00
|
|
|
#ifndef HEADER_LinuxProcess
|
|
|
|
#define HEADER_LinuxProcess
|
|
|
|
/*
|
|
|
|
htop - LinuxProcess.h
|
|
|
|
(C) 2014 Hisham H. Muhammad
|
2020-08-20 09:35:24 +10:00
|
|
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
2020-10-05 09:51:32 +02:00
|
|
|
Released under the GNU GPLv2, see the COPYING file
|
2014-11-27 21:02:52 -02:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
2020-12-06 15:22:41 +01:00
|
|
|
#include "config.h" // IWYU pragma: keep
|
2020-09-19 13:55:23 +02:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "IOPriority.h"
|
|
|
|
#include "Object.h"
|
|
|
|
#include "Process.h"
|
|
|
|
#include "Settings.h"
|
|
|
|
|
2020-11-18 14:26:30 +01:00
|
|
|
|
2020-10-09 15:13:06 +02:00
|
|
|
#define PROCESS_FLAG_LINUX_IOPRIO 0x00000100
|
|
|
|
#define PROCESS_FLAG_LINUX_OPENVZ 0x00000200
|
|
|
|
#define PROCESS_FLAG_LINUX_VSERVER 0x00000400
|
|
|
|
#define PROCESS_FLAG_LINUX_CGROUP 0x00000800
|
|
|
|
#define PROCESS_FLAG_LINUX_OOM 0x00001000
|
|
|
|
#define PROCESS_FLAG_LINUX_SMAPS 0x00002000
|
|
|
|
#define PROCESS_FLAG_LINUX_CTXT 0x00004000
|
|
|
|
#define PROCESS_FLAG_LINUX_SECATTR 0x00008000
|
|
|
|
#define PROCESS_FLAG_LINUX_LRS_FIX 0x00010000
|
2020-11-26 17:51:54 +01:00
|
|
|
#define PROCESS_FLAG_LINUX_CWD 0x00020000
|
2015-03-15 20:29:13 -03:00
|
|
|
|
2015-03-16 01:43:04 -03:00
|
|
|
|
2020-10-17 16:24:45 +05:30
|
|
|
/* LinuxProcessMergedCommand is populated by LinuxProcess_makeCommandStr: It
|
|
|
|
* contains the merged Command string, and the information needed by
|
|
|
|
* LinuxProcess_writeCommand to color the string. str will be NULL for kernel
|
|
|
|
* threads and zombies */
|
|
|
|
typedef struct LinuxProcessMergedCommand_ {
|
|
|
|
char *str; /* merged Command string */
|
|
|
|
int maxLen; /* maximum expected length of Command string */
|
|
|
|
int baseStart; /* basename's start offset */
|
|
|
|
int baseEnd; /* basename's end offset */
|
|
|
|
int commStart; /* comm's start offset */
|
|
|
|
int commEnd; /* comm's end offset */
|
2020-11-20 19:55:48 +01:00
|
|
|
int sep1; /* first field separator, used if non-zero */
|
|
|
|
int sep2; /* second field separator, used if non-zero */
|
2020-10-17 16:24:45 +05:30
|
|
|
bool separateComm; /* whether comm is a separate field */
|
|
|
|
bool unmatchedExe; /* whether exe matched with cmdline */
|
|
|
|
bool cmdlineChanged; /* whether cmdline changed */
|
|
|
|
bool exeChanged; /* whether exe changed */
|
|
|
|
bool commChanged; /* whether comm changed */
|
|
|
|
bool prevMergeSet; /* whether showMergedCommand was set */
|
|
|
|
bool prevPathSet; /* whether showProgramPath was set */
|
|
|
|
bool prevCommSet; /* whether findCommInCmdline was set */
|
|
|
|
bool prevCmdlineSet; /* whether findCommInCmdline was set */
|
|
|
|
} LinuxProcessMergedCommand;
|
|
|
|
|
2014-11-27 21:02:52 -02:00
|
|
|
typedef struct LinuxProcess_ {
|
|
|
|
Process super;
|
2020-10-17 16:24:45 +05:30
|
|
|
char *procComm;
|
|
|
|
char *procExe;
|
|
|
|
int procExeLen;
|
|
|
|
int procExeBasenameOffset;
|
2020-11-23 22:55:56 +01:00
|
|
|
bool procExeDeleted;
|
2020-10-17 16:24:45 +05:30
|
|
|
int procCmdlineBasenameOffset;
|
|
|
|
int procCmdlineBasenameEnd;
|
|
|
|
LinuxProcessMergedCommand mergedCommand;
|
2018-03-25 15:26:05 -03:00
|
|
|
bool isKernelThread;
|
2014-11-27 21:02:52 -02:00
|
|
|
IOPriority ioPriority;
|
2015-03-16 01:43:04 -03:00
|
|
|
unsigned long int cminflt;
|
|
|
|
unsigned long int cmajflt;
|
|
|
|
unsigned long long int utime;
|
|
|
|
unsigned long long int stime;
|
|
|
|
unsigned long long int cutime;
|
|
|
|
unsigned long long int cstime;
|
|
|
|
long m_share;
|
2018-10-09 21:49:29 +02:00
|
|
|
long m_pss;
|
|
|
|
long m_swap;
|
|
|
|
long m_psswp;
|
2015-03-16 01:43:04 -03:00
|
|
|
long m_trs;
|
|
|
|
long m_drs;
|
|
|
|
long m_lrs;
|
|
|
|
long m_dt;
|
|
|
|
unsigned long long io_rchar;
|
|
|
|
unsigned long long io_wchar;
|
|
|
|
unsigned long long io_syscr;
|
|
|
|
unsigned long long io_syscw;
|
|
|
|
unsigned long long io_read_bytes;
|
|
|
|
unsigned long long io_write_bytes;
|
|
|
|
unsigned long long io_cancelled_write_bytes;
|
|
|
|
unsigned long long io_rate_read_time;
|
2019-10-31 11:39:12 -05:00
|
|
|
unsigned long long io_rate_write_time;
|
2015-03-16 01:43:04 -03:00
|
|
|
double io_rate_read_bps;
|
|
|
|
double io_rate_write_bps;
|
|
|
|
#ifdef HAVE_OPENVZ
|
2020-09-30 23:46:52 +02:00
|
|
|
char* ctid;
|
|
|
|
pid_t vpid;
|
2015-03-16 01:43:04 -03:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_VSERVER
|
|
|
|
unsigned int vxid;
|
|
|
|
#endif
|
|
|
|
char* cgroup;
|
|
|
|
unsigned int oom;
|
2016-10-01 03:09:04 -03:00
|
|
|
char* ttyDevice;
|
2017-12-04 00:15:29 -02:00
|
|
|
#ifdef HAVE_DELAYACCT
|
|
|
|
unsigned long long int delay_read_time;
|
|
|
|
unsigned long long cpu_delay_total;
|
|
|
|
unsigned long long blkio_delay_total;
|
|
|
|
unsigned long long swapin_delay_total;
|
|
|
|
float cpu_delay_percent;
|
|
|
|
float blkio_delay_percent;
|
|
|
|
float swapin_delay_percent;
|
|
|
|
#endif
|
2020-09-11 15:02:00 +02:00
|
|
|
unsigned long ctxt_total;
|
|
|
|
unsigned long ctxt_diff;
|
2020-10-31 23:28:02 +01:00
|
|
|
char* secattr;
|
2020-11-16 19:12:41 +01:00
|
|
|
unsigned long long int last_mlrs_calctime;
|
2020-11-26 17:51:54 +01:00
|
|
|
char* cwd;
|
2014-11-27 21:02:52 -02:00
|
|
|
} LinuxProcess;
|
|
|
|
|
2020-10-07 19:02:15 +02:00
|
|
|
#define Process_isKernelThread(_process) (((const LinuxProcess*)(_process))->isKernelThread)
|
2015-03-16 01:43:04 -03:00
|
|
|
|
2020-10-27 21:26:41 +01:00
|
|
|
static inline bool Process_isUserlandThread(const Process* this) {
|
|
|
|
return this->pid != this->tgid;
|
|
|
|
}
|
2015-02-20 14:52:10 -02:00
|
|
|
|
2020-12-10 11:57:48 +11:00
|
|
|
extern int pageSize;
|
|
|
|
|
|
|
|
extern int pageSizeKB;
|
|
|
|
|
2020-12-15 19:44:52 +01:00
|
|
|
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
2015-03-15 20:29:13 -03:00
|
|
|
|
2020-10-13 14:35:30 +02:00
|
|
|
extern const ProcessClass LinuxProcess_class;
|
2015-03-31 23:23:10 -03:00
|
|
|
|
2020-10-21 21:26:05 +02:00
|
|
|
Process* LinuxProcess_new(const Settings* settings);
|
2015-02-20 14:52:10 -02:00
|
|
|
|
2020-09-02 02:38:44 -05:00
|
|
|
void Process_delete(Object* cast);
|
2014-11-27 21:02:52 -02:00
|
|
|
|
2020-09-02 02:38:44 -05:00
|
|
|
IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this);
|
2014-11-27 21:02:52 -02:00
|
|
|
|
2020-10-27 11:46:29 +01:00
|
|
|
bool LinuxProcess_setIOPriority(Process* this, Arg ioprio);
|
2014-11-27 21:02:52 -02:00
|
|
|
|
2020-10-17 16:24:45 +05:30
|
|
|
/* This function constructs the string that is displayed by
|
|
|
|
* LinuxProcess_writeCommand and also returned by LinuxProcess_getCommandStr */
|
|
|
|
void LinuxProcess_makeCommandStr(Process *this);
|
|
|
|
|
2020-10-07 19:02:15 +02:00
|
|
|
bool Process_isThread(const Process* this);
|
2015-03-16 01:43:04 -03:00
|
|
|
|
2014-11-27 21:02:52 -02:00
|
|
|
#endif
|