2006-06-06 20:28:42 +00:00
|
|
|
/* Do not edit this file. It was automatically generated. */
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#ifndef HEADER_Process
|
|
|
|
#define HEADER_Process
|
|
|
|
/*
|
|
|
|
htop - Process.h
|
2015-03-21 19:52:54 +00:00
|
|
|
(C) 2004-2015 Hisham H. Muhammad
|
2006-03-04 18:16:49 +00:00
|
|
|
Released under the GNU GPL, see the COPYING file
|
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
2015-05-20 02:30:11 +00:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
#define SYS_ioprio_get __NR_ioprio_get
|
|
|
|
#define SYS_ioprio_set __NR_ioprio_set
|
|
|
|
#endif
|
|
|
|
|
2014-11-24 20:55:03 +00:00
|
|
|
// On Linux, this works only with glibc 2.1+. On earlier versions
|
2006-03-04 18:16:49 +00:00
|
|
|
// the behavior is similar to have a hardcoded page size.
|
2007-05-17 18:29:30 +00:00
|
|
|
#ifndef PAGE_SIZE
|
2009-03-11 13:15:43 +00:00
|
|
|
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
|
2007-05-17 18:29:30 +00:00
|
|
|
#endif
|
2009-03-11 13:15:43 +00:00
|
|
|
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2011-12-26 21:35:57 +00:00
|
|
|
#include "Object.h"
|
2014-11-24 20:55:03 +00:00
|
|
|
|
2011-12-26 21:35:57 +00:00
|
|
|
#include <sys/types.h>
|
2018-02-04 15:32:41 +00:00
|
|
|
#include <inttypes.h>
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2015-03-15 23:29:13 +00:00
|
|
|
#define PROCESS_FLAG_IO 0x0001
|
2013-05-24 22:46:01 +00:00
|
|
|
|
2015-03-16 04:43:04 +00:00
|
|
|
typedef enum ProcessFields {
|
2016-05-30 15:22:07 +00:00
|
|
|
NULL_PROCESSFIELD = 0,
|
2015-03-16 04:43:04 +00:00
|
|
|
PID = 1,
|
|
|
|
COMM = 2,
|
|
|
|
STATE = 3,
|
|
|
|
PPID = 4,
|
|
|
|
PGRP = 5,
|
|
|
|
SESSION = 6,
|
|
|
|
TTY_NR = 7,
|
|
|
|
TPGID = 8,
|
|
|
|
MINFLT = 10,
|
|
|
|
MAJFLT = 12,
|
|
|
|
PRIORITY = 18,
|
|
|
|
NICE = 19,
|
|
|
|
STARTTIME = 21,
|
2015-03-17 02:01:48 +00:00
|
|
|
PROCESSOR = 38,
|
2015-03-16 04:43:04 +00:00
|
|
|
M_SIZE = 39,
|
|
|
|
M_RESIDENT = 40,
|
|
|
|
ST_UID = 46,
|
|
|
|
PERCENT_CPU = 47,
|
|
|
|
PERCENT_MEM = 48,
|
|
|
|
USER = 49,
|
|
|
|
TIME = 50,
|
|
|
|
NLWP = 51,
|
|
|
|
TGID = 52,
|
|
|
|
} ProcessField;
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2015-08-20 03:32:47 +00:00
|
|
|
typedef struct ProcessPidColumn_ {
|
|
|
|
int id;
|
|
|
|
char* label;
|
|
|
|
} ProcessPidColumn;
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
typedef struct Process_ {
|
|
|
|
Object super;
|
|
|
|
|
2015-01-22 01:27:31 +00:00
|
|
|
struct Settings_* settings;
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2015-03-16 04:43:04 +00:00
|
|
|
unsigned long long int time;
|
2010-02-25 01:43:18 +00:00
|
|
|
pid_t pid;
|
2015-03-16 04:43:04 +00:00
|
|
|
pid_t ppid;
|
|
|
|
pid_t tgid;
|
2006-03-04 18:16:49 +00:00
|
|
|
char* comm;
|
2016-02-02 14:56:52 +00:00
|
|
|
int commLen;
|
2006-03-04 18:16:49 +00:00
|
|
|
int indent;
|
2015-03-15 23:29:13 +00:00
|
|
|
|
|
|
|
int basenameOffset;
|
|
|
|
bool updated;
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
char state;
|
|
|
|
bool tag;
|
2010-06-17 19:02:03 +00:00
|
|
|
bool showChildren;
|
2010-11-22 12:40:20 +00:00
|
|
|
bool show;
|
2007-05-17 18:29:30 +00:00
|
|
|
unsigned int pgrp;
|
|
|
|
unsigned int session;
|
|
|
|
unsigned int tty_nr;
|
2007-11-08 23:23:01 +00:00
|
|
|
int tpgid;
|
2015-03-16 04:43:04 +00:00
|
|
|
uid_t st_uid;
|
2006-03-04 18:16:49 +00:00
|
|
|
unsigned long int flags;
|
2015-03-17 02:01:48 +00:00
|
|
|
int processor;
|
2014-02-27 19:35:22 +00:00
|
|
|
|
|
|
|
float percent_cpu;
|
|
|
|
float percent_mem;
|
|
|
|
char* user;
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
long int priority;
|
|
|
|
long int nice;
|
2007-05-21 19:10:53 +00:00
|
|
|
long int nlwp;
|
2010-03-29 18:36:11 +00:00
|
|
|
char starttime_show[8];
|
|
|
|
time_t starttime_ctime;
|
2014-02-27 19:35:22 +00:00
|
|
|
|
2014-04-10 01:32:54 +00:00
|
|
|
long m_size;
|
|
|
|
long m_resident;
|
2014-02-27 19:35:22 +00:00
|
|
|
|
|
|
|
int exit_signal;
|
|
|
|
|
|
|
|
unsigned long int minflt;
|
|
|
|
unsigned long int majflt;
|
2014-04-24 22:40:47 +00:00
|
|
|
#ifdef DEBUG
|
2014-02-27 19:35:22 +00:00
|
|
|
long int itrealvalue;
|
|
|
|
unsigned long int vsize;
|
|
|
|
long int rss;
|
|
|
|
unsigned long int rlim;
|
|
|
|
unsigned long int startcode;
|
|
|
|
unsigned long int endcode;
|
|
|
|
unsigned long int startstack;
|
|
|
|
unsigned long int kstkesp;
|
|
|
|
unsigned long int kstkeip;
|
|
|
|
unsigned long int signal;
|
|
|
|
unsigned long int blocked;
|
|
|
|
unsigned long int sigignore;
|
|
|
|
unsigned long int sigcatch;
|
|
|
|
unsigned long int wchan;
|
|
|
|
unsigned long int nswap;
|
|
|
|
unsigned long int cnswap;
|
|
|
|
#endif
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
} Process;
|
|
|
|
|
2015-01-22 01:27:31 +00:00
|
|
|
typedef struct ProcessFieldData_ {
|
|
|
|
const char* name;
|
|
|
|
const char* title;
|
|
|
|
const char* description;
|
2018-01-31 02:52:08 +00:00
|
|
|
uint64_t flags;
|
2015-01-22 01:27:31 +00:00
|
|
|
} ProcessFieldData;
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2015-03-16 04:43:04 +00:00
|
|
|
// Implemented in platform-specific code:
|
2015-01-22 01:27:31 +00:00
|
|
|
void Process_writeField(Process* this, RichString* str, ProcessField field);
|
|
|
|
long Process_compare(const void* v1, const void* v2);
|
2015-03-16 04:43:04 +00:00
|
|
|
void Process_delete(Object* cast);
|
|
|
|
bool Process_isThread(Process* this);
|
|
|
|
extern ProcessFieldData Process_fields[];
|
2015-08-20 03:32:47 +00:00
|
|
|
extern ProcessPidColumn Process_pidColumns[];
|
|
|
|
extern char Process_pidFormat[20];
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2015-04-02 04:57:37 +00:00
|
|
|
typedef Process*(*Process_New)(struct Settings_*);
|
2015-04-01 02:23:10 +00:00
|
|
|
typedef void (*Process_WriteField)(Process*, RichString*, ProcessField);
|
|
|
|
|
|
|
|
typedef struct ProcessClass_ {
|
|
|
|
const ObjectClass super;
|
|
|
|
const Process_WriteField writeField;
|
|
|
|
} ProcessClass;
|
|
|
|
|
|
|
|
#define As_Process(this_) ((ProcessClass*)((this_)->super.klass))
|
2015-03-17 02:01:48 +00:00
|
|
|
|
2017-09-14 20:10:39 +00:00
|
|
|
#define Process_isChildOf(process_, pid_) (process_->tgid == pid_ || (process_->tgid == process_->pid && process_->ppid == pid_))
|
|
|
|
|
2018-01-14 09:08:20 +00:00
|
|
|
#define Process_sortState(state) ((state) == 'I' ? 0x100 : (state))
|
|
|
|
|
2013-05-24 22:46:01 +00:00
|
|
|
|
2014-04-10 01:49:36 +00:00
|
|
|
#define ONE_K 1024L
|
2008-03-09 08:58:38 +00:00
|
|
|
#define ONE_M (ONE_K * ONE_K)
|
|
|
|
#define ONE_G (ONE_M * ONE_K)
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2014-04-10 01:49:36 +00:00
|
|
|
#define ONE_DECIMAL_K 1000L
|
2014-02-27 19:35:22 +00:00
|
|
|
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
|
2014-04-10 01:32:54 +00:00
|
|
|
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
|
2014-02-27 19:35:22 +00:00
|
|
|
|
2015-12-14 15:27:11 +00:00
|
|
|
extern char Process_pidFormat[20];
|
|
|
|
|
2015-08-20 03:32:47 +00:00
|
|
|
void Process_setupColumnWidths();
|
|
|
|
|
2015-03-16 04:43:04 +00:00
|
|
|
void Process_humanNumber(RichString* str, unsigned long number, bool coloring);
|
|
|
|
|
|
|
|
void Process_colorNumber(RichString* str, unsigned long long number, bool coloring);
|
|
|
|
|
2015-03-17 02:01:48 +00:00
|
|
|
void Process_printTime(RichString* str, unsigned long long totalHundredths);
|
2015-03-16 04:43:04 +00:00
|
|
|
|
|
|
|
void Process_outputRate(RichString* str, char* buffer, int n, double rate, int coloring);
|
|
|
|
|
2018-01-31 02:52:08 +00:00
|
|
|
void Process_printPercentage(float val, char* buffer, int n, int* attr);
|
|
|
|
|
2015-04-01 02:23:10 +00:00
|
|
|
void Process_writeField(Process* this, RichString* str, ProcessField field);
|
|
|
|
|
|
|
|
void Process_display(Object* cast, RichString* out);
|
2015-01-22 01:27:31 +00:00
|
|
|
|
2015-02-20 16:52:10 +00:00
|
|
|
void Process_done(Process* this);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2015-04-01 02:23:10 +00:00
|
|
|
extern ProcessClass Process_class;
|
2012-12-05 15:12:20 +00:00
|
|
|
|
2015-02-20 16:52:10 +00:00
|
|
|
void Process_init(Process* this, struct Settings_* settings);
|
2008-03-09 08:58:38 +00:00
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
void Process_toggleTag(Process* this);
|
|
|
|
|
2007-12-17 05:57:28 +00:00
|
|
|
bool Process_setPriority(Process* this, int priority);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2012-10-04 23:59:45 +00:00
|
|
|
bool Process_changePriorityBy(Process* this, size_t delta);
|
|
|
|
|
|
|
|
void Process_sendSignal(Process* this, size_t sgn);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2014-04-25 22:41:23 +00:00
|
|
|
long Process_pidCompare(const void* v1, const void* v2);
|
2006-07-11 06:13:32 +00:00
|
|
|
|
2014-04-25 22:41:23 +00:00
|
|
|
long Process_compare(const void* v1, const void* v2);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#endif
|