Process.h 4.42 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
7
8
9
10
11
12
13
14
15
16

#ifndef HEADER_Process
#define HEADER_Process
/*
htop - Process.h
(C) 2004-2006 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/

#define _GNU_SOURCE
#include "ProcessList.h"
#include "Object.h"
#include "CRT.h"
#include "String.h"
17
#include "RichString.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31

#include "debug.h"

#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <stdbool.h>
#include <pwd.h>
32
#include <sched.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
33

Hisham Muhammad's avatar
Hisham Muhammad committed
34
#ifdef HAVE_PLPA
35
#include <plpa.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
36
#endif
37

Hisham Muhammad's avatar
Hisham Muhammad committed
38
39
// This works only with glibc 2.1+. On earlier versions
// the behavior is similar to have a hardcoded page size.
40
#ifndef PAGE_SIZE
Hisham Muhammad's avatar
Hisham Muhammad committed
41
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
42
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
43
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
Hisham Muhammad's avatar
Hisham Muhammad committed
44
45
46
47

#define PROCESS_COMM_LEN 300


Hisham Muhammad's avatar
Hisham Muhammad committed
48
#ifndef Process_isThread
Hisham Muhammad's avatar
Hisham Muhammad committed
49
#define Process_isThread(_process) (_process->pid != _process->tgid || _process->m_size == 0)
Hisham Muhammad's avatar
Hisham Muhammad committed
50
51
#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
52
53
54
55
56
typedef enum ProcessField_ {
   PID = 1, COMM, STATE, PPID, PGRP, SESSION, TTY_NR, TPGID, FLAGS, MINFLT, CMINFLT, MAJFLT, CMAJFLT, UTIME,
   STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE,
   STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL,
   PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM,
57
   USER, TIME, NLWP, TGID,
58
   #ifdef HAVE_OPENVZ
59
   CTID, VPID,
60
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
61
62
63
   #ifdef HAVE_VSERVER
   VXID,
   #endif
64
   #ifdef HAVE_TASKSTATS
65
   RCHAR, WCHAR, SYSCR, SYSCW, RBYTES, WBYTES, CNCLWB, IO_READ_RATE, IO_WRITE_RATE, IO_RATE,
66
   #endif
67
   LAST_PROCESSFIELD
Hisham Muhammad's avatar
Hisham Muhammad committed
68
69
70
71
72
73
74
75
76
77
} ProcessField;

struct ProcessList_;

typedef struct Process_ {
   Object super;

   struct ProcessList_ *pl;
   bool updated;

Hisham Muhammad's avatar
Hisham Muhammad committed
78
   pid_t pid;
Hisham Muhammad's avatar
Hisham Muhammad committed
79
80
81
82
   char* comm;
   int indent;
   char state;
   bool tag;
Hisham Muhammad's avatar
Hisham Muhammad committed
83
   pid_t ppid;
84
85
86
   unsigned int pgrp;
   unsigned int session;
   unsigned int tty_nr;
Hisham Muhammad's avatar
Hisham Muhammad committed
87
   pid_t tgid;
88
   int tpgid;
Hisham Muhammad's avatar
Hisham Muhammad committed
89
   unsigned long int flags;
90
   #ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
91
92
93
94
   unsigned long int minflt;
   unsigned long int cminflt;
   unsigned long int majflt;
   unsigned long int cmajflt;
95
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
96
97
98
99
100
101
   unsigned long int utime;
   unsigned long int stime;
   long int cutime;
   long int cstime;
   long int priority;
   long int nice;
102
   long int nlwp;
103
   #ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
   long int itrealvalue;
   unsigned long int starttime;
   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;
121
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
122
123
124
125
126
127
128
129
130
131
132
133
   int exit_signal;
   int processor;
   int m_size;
   int m_resident;
   int m_share;
   int m_trs;
   int m_drs;
   int m_lrs;
   int m_dt;
   uid_t st_uid;
   float percent_cpu;
   float percent_mem;
134
   char* user;
135
   #ifdef HAVE_OPENVZ
136
   unsigned int ctid;
137
138
   unsigned int vpid;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
139
140
141
   #ifdef HAVE_VSERVER
   unsigned int vxid;
   #endif
142
143
144
145
146
147
148
149
150
151
152
153
154
   #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;
   double io_rate_read_bps;
   unsigned long long io_rate_read_time;
   double io_rate_write_bps;
   unsigned long long io_rate_write_time;   
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
155
156
157
} Process;


158
#ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
159
extern char* PROCESS_CLASS;
160
161
162
#else
#define PROCESS_CLASS NULL
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
163

Hisham Muhammad's avatar
Hisham Muhammad committed
164
extern const char *Process_fieldNames[];
Hisham Muhammad's avatar
Hisham Muhammad committed
165

Hisham Muhammad's avatar
Hisham Muhammad committed
166
extern const char *Process_fieldTitles[];
167

168
169
170
#define ONE_K 1024
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)
Hisham Muhammad's avatar
Hisham Muhammad committed
171
172
173

void Process_delete(Object* cast);

174
175
176
Process* Process_new(struct ProcessList_ *pl);

Process* Process_clone(Process* this);
Hisham Muhammad's avatar
Hisham Muhammad committed
177
178
179

void Process_toggleTag(Process* this);

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

Hisham Muhammad's avatar
Hisham Muhammad committed
182
#ifdef HAVE_PLPA
183
184
unsigned long Process_getAffinity(Process* this);

185
bool Process_setAffinity(Process* this, unsigned long mask);
Hisham Muhammad's avatar
Hisham Muhammad committed
186
#endif
187

Hisham Muhammad's avatar
Hisham Muhammad committed
188
void Process_sendSignal(Process* this, int sgn);
Hisham Muhammad's avatar
Hisham Muhammad committed
189

190
191
192
int Process_pidCompare(const void* v1, const void* v2);

int Process_compare(const void* v1, const void* v2);
Hisham Muhammad's avatar
Hisham Muhammad committed
193
194

#endif