Process.h 4.04 KB
Newer Older
Hisham Muhammad's avatar
Hisham Muhammad committed
1
/* Do not edit this file. It was automatically generated. */
Hisham Muhammad's avatar
Hisham Muhammad committed
2
3
4
5
6

#ifndef HEADER_Process
#define HEADER_Process
/*
htop - Process.h
7
(C) 2004-2014 Hisham H. Muhammad
Hisham Muhammad's avatar
Hisham Muhammad committed
8
9
10
11
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/

12
// On Linux, this works only with glibc 2.1+. On earlier versions
Hisham Muhammad's avatar
Hisham Muhammad committed
13
// the behavior is similar to have a hardcoded page size.
14
#ifndef PAGE_SIZE
Hisham Muhammad's avatar
Hisham Muhammad committed
15
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
16
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
17
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
Hisham Muhammad's avatar
Hisham Muhammad committed
18

Hisham Muhammad's avatar
Hisham Muhammad committed
19
#include "Object.h"
20

Hisham Muhammad's avatar
Hisham Muhammad committed
21
#include <sys/types.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
22

23
#define PROCESS_FLAG_IO 0x0001
24

25
26
27
28
29
30
31
#ifndef Process_isKernelThread
#define Process_isKernelThread(_process) (_process->pgrp == 0)
#endif

#ifndef Process_isUserlandThread
#define Process_isUserlandThread(_process) (_process->pid != _process->tgid)
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
32

Hisham Muhammad's avatar
Hisham Muhammad committed
33
#ifndef Process_isThread
34
#define Process_isThread(_process) (Process_isUserlandThread(_process) || Process_isKernelThread(_process))
Hisham Muhammad's avatar
Hisham Muhammad committed
35
36
#endif

37
typedef int ProcessField;
Hisham Muhammad's avatar
Hisham Muhammad committed
38
39
40
41

typedef struct Process_ {
   Object super;

Hisham Muhammad's avatar
Hisham Muhammad committed
42
   struct Settings_* settings;
Hisham Muhammad's avatar
Hisham Muhammad committed
43

Hisham Muhammad's avatar
Hisham Muhammad committed
44
   pid_t pid;
Hisham Muhammad's avatar
Hisham Muhammad committed
45
46
   char* comm;
   int indent;
47
48
49
50

   int basenameOffset;
   bool updated;

Hisham Muhammad's avatar
Hisham Muhammad committed
51
52
   char state;
   bool tag;
Hisham Muhammad's avatar
Hisham Muhammad committed
53
   bool showChildren;
54
   bool show;
Hisham Muhammad's avatar
Hisham Muhammad committed
55
   pid_t ppid;
56
57
58
   unsigned int pgrp;
   unsigned int session;
   unsigned int tty_nr;
Hisham Muhammad's avatar
Hisham Muhammad committed
59
   pid_t tgid;
60
   int tpgid;
Hisham Muhammad's avatar
Hisham Muhammad committed
61
   unsigned long int flags;
Hisham Muhammad's avatar
Hisham Muhammad committed
62
63
64
65
66
67

   uid_t st_uid;
   float percent_cpu;
   float percent_mem;
   char* user;

68
69
70
71
   unsigned long long int utime;
   unsigned long long int stime;
   unsigned long long int cutime;
   unsigned long long int cstime;
Hisham Muhammad's avatar
Hisham Muhammad committed
72
73
   long int priority;
   long int nice;
74
   long int nlwp;
Hisham Muhammad's avatar
Hisham Muhammad committed
75
76
   char starttime_show[8];
   time_t starttime_ctime;
Hisham Muhammad's avatar
Hisham Muhammad committed
77
78
79
80
81
82
83
84
85
86
87

   #ifdef HAVE_TASKSTATS
   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;
   unsigned long long io_rate_write_time;   
Hisham Muhammad's avatar
Hisham Muhammad committed
88
89
   double io_rate_read_bps;
   double io_rate_write_bps;
90
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
91

Hisham Muhammad's avatar
Hisham Muhammad committed
92
   int processor;
93
94
95
96
97
98
99
   long m_size;
   long m_resident;
   long m_share;
   long m_trs;
   long m_drs;
   long m_lrs;
   long m_dt;
Hisham Muhammad's avatar
Hisham Muhammad committed
100

101
   #ifdef HAVE_OPENVZ
102
   unsigned int ctid;
103
104
   unsigned int vpid;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
105
106
107
   #ifdef HAVE_VSERVER
   unsigned int vxid;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
108

109
110
111
   #ifdef HAVE_CGROUP
   char* cgroup;
   #endif
112
113
114
   #ifdef HAVE_OOM
   unsigned int oom;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
115
116
117
118
119
120
121

   int exit_signal;

   unsigned long int minflt;
   unsigned long int cminflt;
   unsigned long int majflt;
   unsigned long int cmajflt;
122
   #ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
   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

Hisham Muhammad's avatar
Hisham Muhammad committed
141
142
} Process;

Hisham Muhammad's avatar
Hisham Muhammad committed
143
144
145
146
147
148
typedef struct ProcessFieldData_ {
   const char* name;
   const char* title;
   const char* description;
   int flags;
} ProcessFieldData;
Hisham Muhammad's avatar
Hisham Muhammad committed
149

Hisham Muhammad's avatar
Hisham Muhammad committed
150
151
void Process_writeField(Process* this, RichString* str, ProcessField field);
long Process_compare(const void* v1, const void* v2);
Hisham Muhammad's avatar
Hisham Muhammad committed
152

153

154
#define ONE_K 1024L
155
156
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)
Hisham Muhammad's avatar
Hisham Muhammad committed
157

158
#define ONE_DECIMAL_K 1000L
Hisham Muhammad's avatar
Hisham Muhammad committed
159
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
160
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
Hisham Muhammad's avatar
Hisham Muhammad committed
161

Hisham Muhammad's avatar
Hisham Muhammad committed
162
163
void Process_writeDefaultField(Process* this, RichString* str, ProcessField field);

164
void Process_done(Process* this);
Hisham Muhammad's avatar
Hisham Muhammad committed
165

166
167
extern ObjectClass Process_class;

168
void Process_init(Process* this, struct Settings_* settings);
169

Hisham Muhammad's avatar
Hisham Muhammad committed
170
171
void Process_toggleTag(Process* this);

172
bool Process_setPriority(Process* this, int priority);
Hisham Muhammad's avatar
Hisham Muhammad committed
173

174
175
176
bool Process_changePriorityBy(Process* this, size_t delta);

void Process_sendSignal(Process* this, size_t sgn);
Hisham Muhammad's avatar
Hisham Muhammad committed
177

178
long Process_pidCompare(const void* v1, const void* v2);
179

Hisham Muhammad's avatar
Hisham Muhammad committed
180
long Process_defaultCompare(const void* v1, const void* v2);
Hisham Muhammad's avatar
Hisham Muhammad committed
181
182

#endif