Process.h 3.71 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
typedef enum ProcessFields {
   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,
   M_SIZE = 39,
   M_RESIDENT = 40,
   ST_UID = 46,
   PERCENT_CPU = 47,
   PERCENT_MEM = 48,
   USER = 49,
   TIME = 50,
   NLWP = 51,
   TGID = 52,
} ProcessField;
Hisham Muhammad's avatar
Hisham Muhammad committed
49
50
51
52

typedef struct Process_ {
   Object super;

Hisham Muhammad's avatar
Hisham Muhammad committed
53
   struct Settings_* settings;
Hisham Muhammad's avatar
Hisham Muhammad committed
54

55
   unsigned long long int time;
Hisham Muhammad's avatar
Hisham Muhammad committed
56
   pid_t pid;
57
58
   pid_t ppid;
   pid_t tgid;
Hisham Muhammad's avatar
Hisham Muhammad committed
59
60
   char* comm;
   int indent;
61
62
63
64

   int basenameOffset;
   bool updated;

Hisham Muhammad's avatar
Hisham Muhammad committed
65
66
   char state;
   bool tag;
Hisham Muhammad's avatar
Hisham Muhammad committed
67
   bool showChildren;
68
   bool show;
69
70
71
   unsigned int pgrp;
   unsigned int session;
   unsigned int tty_nr;
72
   int tpgid;
73
   uid_t st_uid;
Hisham Muhammad's avatar
Hisham Muhammad committed
74
   unsigned long int flags;
Hisham Muhammad's avatar
Hisham Muhammad committed
75
76
77
78
79

   float percent_cpu;
   float percent_mem;
   char* user;

Hisham Muhammad's avatar
Hisham Muhammad committed
80
81
   long int priority;
   long int nice;
82
   long int nlwp;
Hisham Muhammad's avatar
Hisham Muhammad committed
83
84
   char starttime_show[8];
   time_t starttime_ctime;
Hisham Muhammad's avatar
Hisham Muhammad committed
85

86
87
   long m_size;
   long m_resident;
Hisham Muhammad's avatar
Hisham Muhammad committed
88
89
90
91
92

   int exit_signal;

   unsigned long int minflt;
   unsigned long int majflt;
93
   #ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
   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
112
113
} Process;

Hisham Muhammad's avatar
Hisham Muhammad committed
114
115
116
117
118
119
typedef struct ProcessFieldData_ {
   const char* name;
   const char* title;
   const char* description;
   int flags;
} ProcessFieldData;
Hisham Muhammad's avatar
Hisham Muhammad committed
120

121
122
// Implemented in platform-specific code:
void Process_setupColumnWidths();
Hisham Muhammad's avatar
Hisham Muhammad committed
123
124
void Process_writeField(Process* this, RichString* str, ProcessField field);
long Process_compare(const void* v1, const void* v2);
125
126
127
128
129
void Process_delete(Object* cast);
bool Process_isThread(Process* this);
extern ProcessFieldData Process_fields[];
extern char* Process_pidFormat;
extern char* Process_tpgidFormat;
Hisham Muhammad's avatar
Hisham Muhammad committed
130

131

132
#define ONE_K 1024L
133
134
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)
Hisham Muhammad's avatar
Hisham Muhammad committed
135

136
#define ONE_DECIMAL_K 1000L
Hisham Muhammad's avatar
Hisham Muhammad committed
137
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
138
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
Hisham Muhammad's avatar
Hisham Muhammad committed
139

140
141
142
143
144
145
146
147
void Process_humanNumber(RichString* str, unsigned long number, bool coloring);

void Process_colorNumber(RichString* str, unsigned long long number, bool coloring);

void Process_printTime(RichString* str, unsigned long long t);

void Process_outputRate(RichString* str, char* buffer, int n, double rate, int coloring);

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

150
void Process_done(Process* this);
Hisham Muhammad's avatar
Hisham Muhammad committed
151

152
153
extern ObjectClass Process_class;

154
void Process_init(Process* this, struct Settings_* settings);
155

Hisham Muhammad's avatar
Hisham Muhammad committed
156
157
void Process_toggleTag(Process* this);

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

160
161
162
bool Process_changePriorityBy(Process* this, size_t delta);

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

164
long Process_pidCompare(const void* v1, const void* v2);
165

Hisham Muhammad's avatar
Hisham Muhammad committed
166
long Process_defaultCompare(const void* v1, const void* v2);
Hisham Muhammad's avatar
Hisham Muhammad committed
167
168

#endif