File: Linux.h

package info (click to toggle)
libproc-process-perl 0.41-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 456 kB
  • ctags: 536
  • sloc: ansic: 3,828; perl: 343; makefile: 42
file content (191 lines) | stat: -rw-r--r-- 3,085 bytes parent folder | download
1
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#include <fcntl.h>
#include <asm/param.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <linux/limits.h>

/****************************************/
/* Process state strings that we return */
/****************************************/
#define SLEEP  "sleep"
#define WAIT   "wait"       
#define RUN    "run"
#define IDLE   "idle"
#define ZOMBIE "defunct"
#define STOP   "stop"
#define UWAIT  "uwait"      

/***********************************************************/
/* Some global variables we only need to get once          */
/***********************************************************/
long Btime;
unsigned Sysmem;

/***********************************************************/
/* stuff stored in /proc/xxx/stat it would be nice if this */
/* was in a system header file somewhere                   */
/***********************************************************/
struct procstat {
  int pid;
  char comm[FILENAME_MAX];
  char state;
  int ppid;
  int pgrp;
  int session;
  int tty;
  int tpgid;
  unsigned flags;
  unsigned minflt;
  unsigned cminflt;
  unsigned majflt;
  unsigned cmajflt;
  long long utime;
  long long stime;
  long long cutime;
  long long cstime;
  int counter;
  int priority;
  unsigned timeout;
  unsigned itrealvalue;
  unsigned long  starttime;
  unsigned vsize;
  unsigned rss;
  unsigned rlim;
  unsigned startcode;
  unsigned endcode;
  unsigned startstack;
  unsigned kstkesp;
  unsigned kstkeip;
  int signal;
  int blocked;
  int sigignore;
  int sigcatch;
  unsigned wchan;
};

/* We need to pass in a cap for ignore, lower for store on object */
/* We can just lc these! */
static char Defaultformat[] = "IIIIIIIIIIIIIJJJJJJUIISLSSSSSIIIIIIS";

/* Mapping of field to type */
static char* Fields[] = {
  "uid",
#define F_UID 0 

  "gid",
#define F_GID 1

  "pid",
#define F_PID 2

  "ppid",
#define F_PPID 3

  "pgrp",
#define F_PGRP 4

  "sess",
#define F_SESS 5

  "priority",
#define F_PRIORITY 6

  "ttynum",
#define F_TTYNUM 7

  "flags",
#define F_FLAGS 8

  "minflt",
#define F_MINFLT 9

  "cminflt",
#define F_CMINFLT 10

  "majflt",
#define F_MAJFLT 11

  "cmajflt",
#define F_CMAJFLT 12

  "utime",
#define F_UTIME 13

  "stime",
#define F_STIME 14

  "cutime",
#define F_CUTIME 15

  "cstime",
#define F_CSTIME 16

  "time",
#define F_TIME 17

  "ctime",
#define F_CTIME 18

  "size",
#define F_SIZE 19

  "rss",
#define F_RSS 20

  "wchan",
#define F_WCHAN 21

  "fname",
#define F_FNAME 22

  "start",
#define F_START 23

  "pctcpu",
#define F_PCTCPU 24

  "state",
#define F_STATE 25

  "pctmem",
#define F_PCTMEM 26

  "cmndline",
#define F_CMNDLINE 27

  "exec",
#define F_EXEC 28

  "euid",
#define F_EUID 29

  "suid", 
#define F_SUID 30

  "fuid",
#define F_FUID 31

  "egid", 
#define F_EGID 32

  "sgid", 
#define F_SGID 33

  "fgid",
#define F_FGID 34

  "cwd"
#define F_CWD 35

#define F_LASTFIELD 35
};