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
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

#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"

#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>
31
#include <sched.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
32

33
34
#include <plpa.h>

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

#define PROCESS_COMM_LEN 300


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,
49
   USER, TIME, NLWP, TGID,
50
51
52
53
   #ifdef HAVE_OPENVZ
   VEID, VPID,
   #endif
   LAST_PROCESSFIELD
Hisham Muhammad's avatar
Hisham Muhammad committed
54
55
56
57
58
59
60
61
62
63
} ProcessField;

struct ProcessList_;

typedef struct Process_ {
   Object super;

   struct ProcessList_ *pl;
   bool updated;

64
   unsigned int pid;
Hisham Muhammad's avatar
Hisham Muhammad committed
65
66
67
68
   char* comm;
   int indent;
   char state;
   bool tag;
69
70
71
72
   unsigned int ppid;
   unsigned int pgrp;
   unsigned int session;
   unsigned int tty_nr;
73
74
   unsigned int tgid;
   int tpgid;
Hisham Muhammad's avatar
Hisham Muhammad committed
75
   unsigned long int flags;
76
   #ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
77
78
79
80
   unsigned long int minflt;
   unsigned long int cminflt;
   unsigned long int majflt;
   unsigned long int cmajflt;
81
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
82
83
84
85
86
87
   unsigned long int utime;
   unsigned long int stime;
   long int cutime;
   long int cstime;
   long int priority;
   long int nice;
88
   long int nlwp;
89
   #ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
   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;
107
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
108
109
110
111
112
113
114
115
116
117
118
119
   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;
120
   char* user;
121
122
123
124
   #ifdef HAVE_OPENVZ
   unsigned int veid;
   unsigned int vpid;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
125
126
127
} Process;


128
#ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
129
extern char* PROCESS_CLASS;
130
131
132
#else
#define PROCESS_CLASS NULL
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
133

Hisham Muhammad's avatar
Hisham Muhammad committed
134
extern char *Process_fieldNames[];
Hisham Muhammad's avatar
Hisham Muhammad committed
135
136
137
138
139
140
141
142
143
144
145

Process* Process_new(struct ProcessList_ *pl);

Process* Process_clone(Process* this);

void Process_delete(Object* cast);

void Process_display(Object* cast, RichString* out);

void Process_toggleTag(Process* this);

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

148
149
unsigned long Process_getAffinity(Process* this);

150
bool Process_setAffinity(Process* this, unsigned long mask);
151

Hisham Muhammad's avatar
Hisham Muhammad committed
152
153
154
155
156
157
158
159
void Process_sendSignal(Process* this, int signal);

#define ONE_K 1024
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)

void Process_writeField(Process* this, RichString* str, ProcessField field);

160
161
162
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
163
164
165
166

char* Process_printField(ProcessField field);

#endif