htop/Process.h

211 lines
5.0 KiB
C
Raw Normal View History

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
(C) 2020 Red Hat, Inc. All Rights Reserved.
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.
*/
2018-02-26 14:44:00 +00:00
#ifdef MAJOR_IN_MKDEV
#elif defined(MAJOR_IN_SYSMACROS)
2018-02-26 14:44:00 +00:00
#endif
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
// 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.
#ifndef PAGE_SIZE
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
#endif
#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"
2011-12-26 21:35:57 +00:00
#include <sys/types.h>
2006-03-04 18:16:49 +00:00
#define PROCESS_FLAG_IO 0x0001
typedef enum ProcessFields {
2016-05-30 15:22:07 +00:00
NULL_PROCESSFIELD = 0,
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,
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
typedef struct ProcessPidColumn_ {
int id;
char* label;
} ProcessPidColumn;
2006-03-04 18:16:49 +00:00
typedef struct Process_ {
Object super;
struct Settings_* settings;
2006-03-04 18:16:49 +00:00
unsigned long long int time;
2010-02-25 01:43:18 +00:00
pid_t pid;
pid_t ppid;
pid_t tgid;
2006-03-04 18:16:49 +00:00
char* comm;
int commLen;
2006-03-04 18:16:49 +00:00
int indent;
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;
bool show;
unsigned int pgrp;
unsigned int session;
unsigned int tty_nr;
int tpgid;
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;
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
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;
typedef struct ProcessFieldData_ {
const char* name;
const char* title;
const char* description;
int flags;
} ProcessFieldData;
2006-03-04 18:16:49 +00:00
// Implemented in platform-specific code:
void Process_writeField(Process* this, RichString* str, ProcessField field);
long Process_compare(const void* v1, const void* v2);
void Process_delete(Object* cast);
bool Process_isThread(Process* this);
extern ProcessFieldData Process_fields[];
extern ProcessPidColumn Process_pidColumns[];
extern char Process_pidFormat[20];
2006-03-04 18:16:49 +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
#define Process_getParentPid(process_) (process_->tgid == process_->pid ? process_->ppid : process_->tgid)
#define Process_isChildOf(process_, pid_) (process_->tgid == pid_ || (process_->tgid == process_->pid && process_->ppid == pid_))
#define Process_sortState(state) ((state) == 'I' ? 0x100 : (state))
#define ONE_K 1024L
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)
#define ONE_T ((long long)ONE_G * ONE_K)
2006-03-04 18:16:49 +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)
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
#define ONE_DECIMAL_T ((long long)ONE_DECIMAL_G * ONE_DECIMAL_K)
2014-02-27 19:35:22 +00:00
extern char Process_pidFormat[20];
extern void Process_setupColumnWidths();
extern void Process_humanNumber(RichString* str, unsigned long number, bool coloring);
extern void Process_colorNumber(RichString* str, unsigned long long number, bool coloring);
extern void Process_printTime(RichString* str, unsigned long long totalHundredths);
extern void Process_outputRate(RichString* str, char* buffer, int n, double rate, int coloring);
extern void Process_writeField(Process* this, RichString* str, ProcessField field);
2015-04-01 02:23:10 +00:00
extern void Process_display(Object* cast, RichString* out);
extern 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;
extern void Process_init(Process* this, struct Settings_* settings);
extern void Process_toggleTag(Process* this);
2006-03-04 18:16:49 +00:00
extern bool Process_setPriority(Process* this, int priority);
2006-03-04 18:16:49 +00:00
extern bool Process_changePriorityBy(Process* this, Arg delta);
2012-10-04 23:59:45 +00:00
extern bool Process_sendSignal(Process* this, Arg sgn);
2006-03-04 18:16:49 +00:00
extern long Process_pidCompare(const void* v1, const void* v2);
extern long Process_compare(const void* v1, const void* v2);
2006-03-04 18:16:49 +00:00
#endif