libsysactivity  0.6.5
 All Data Structures Functions Variables Enumerations Enumerator Modules
process.h
1 /*
2  * libsysactivity
3  * http://sourceforge.net/projects/libsysactivity/
4  * Copyright (c) 2009, 2010 Carlos Olmedo Escobar <carlos.olmedo.e@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
25 #ifndef SA_PROCESS_H_
26 #define SA_PROCESS_H_
27 
28 #include <sys/types.h>
29 
34  SA_UNKNOWN = 0,
35  SA_RUNNING = 1,
38  SA_ZOMBIE = 4,
39  SA_STOPPED = 5,
40 };
41 
46 #ifdef SA_PROCESS_PID
47  pid_t pid;
48 #endif
49 #ifdef SA_PROCESS_STATE
51 #endif
52 #ifdef SA_PROCESS_USER_TIME // TODO Explain these better
53  uint64_t user_time;
54 #endif
55 #ifdef SA_PROCESS_SYS_TIME
56  uint64_t sys_time;
57 #endif
58 #ifdef SA_PROCESS_THREADS
59  uint32_t threads;
60 #endif
61 #ifdef SA_PROCESS_VM_SIZE
62  uint32_t vm_size;
63 #endif
64 #ifdef SA_PROCESS_RSS
65  uint32_t rss;
66 #endif
67 };
68 
72 struct sa_process {
73 #ifdef SA_PROCESS_PID
74  pid_t pid;
75 #endif
76 #ifdef SA_PROCESS_UID
77  uid_t uid;
78 #endif
79 #ifdef SA_PROCESS_GID
80  gid_t gid;
81 #endif
82 #ifdef SA_PROCESS_FILENAME
83  char filename[SA_PROCESS_FILENAME];
84 #endif
85 #ifdef SA_PROCESS_CMDLINE
86  char cmdline[SA_PROCESS_CMDLINE];
87 #endif
88 #ifdef SA_PROCESS_PARENT_PID
89  pid_t parent_pid;
90 #endif
91 #ifdef SA_PROCESS_PGRP
92  pid_t pgrp;
93 #endif
94 #ifdef SA_PROCESS_SID
95  pid_t sid;
96 #endif
97 #ifdef SA_PROCESS_TTY
98  pid_t tty;
99 #endif
100 #ifdef SA_PROCESS_NICE
101  int8_t nice;
102 #endif
103 #ifdef SA_PROCESS_START_TIME
104  uint64_t start_time;
105 #endif
106 struct sa_process_activity activity;
107 };
108 
109 #ifdef SA_OPEN_PROCESS
110 
115 int sa_open_process() SA_EXPORT;
116 #endif
117 
118 #ifdef SA_CLOSE_PROCESS
119 
124 int sa_close_process() SA_EXPORT;
125 #endif
126 
132 int sa_count_processes(uint32_t* number) SA_EXPORT SA_NONNULL;
133 
142 int sa_get_processes_ids(pid_t* dst, uint32_t dst_size, uint32_t* written) SA_EXPORT SA_NONNULL;
143 
150 int sa_get_process(pid_t pid, struct sa_process* dst) SA_EXPORT SA_NONNULL;
151 
159 int sa_get_process_activity(pid_t pid, struct sa_process_activity* dst) SA_EXPORT SA_NONNULL;
160 
162 #endif /* SA_PROCESS_H_ */
int sa_get_process(pid_t pid, struct sa_process *dst) SA_EXPORT SA_NONNULL
sa_process_state
Definition: process.h:33
pid_t pgrp
The group id the process.
Definition: process.h:92
int sa_count_processes(uint32_t *number) SA_EXPORT SA_NONNULL
The state is unknown.
Definition: process.h:34
The process is running.
Definition: process.h:35
int sa_open_process() SA_EXPORT
uint64_t sys_time
Kernel mode jiffies.
Definition: process.h:56
gid_t gid
Id of the user's group running this process.
Definition: process.h:80
uint64_t start_time
Process start time in hundredths of second since system boot.
Definition: process.h:104
pid_t tty
The id of the tty this process is running on.
Definition: process.h:98
pid_t pid
The id of the process.
Definition: process.h:47
char filename[SA_PROCESS_FILENAME]
The name of the running file.
Definition: process.h:83
pid_t pid
The id of the process.
Definition: process.h:74
Definition: process.h:45
int sa_get_process_activity(pid_t pid, struct sa_process_activity *dst) SA_EXPORT SA_NONNULL
uint32_t rss
Resident Set memory Size.
Definition: process.h:65
The process is sleeping.
Definition: process.h:36
The process is an uninterruptible sleep.
Definition: process.h:37
int sa_close_process() SA_EXPORT
uint32_t vm_size
Virtual memory size.
Definition: process.h:62
Definition: process.h:72
uint32_t threads
Number of threads.
Definition: process.h:59
uint64_t user_time
User mode jiffies.
Definition: process.h:53
enum sa_process_state state
The current state of the process.
Definition: process.h:50
int8_t nice
Priority of this process.
Definition: process.h:101
int sa_get_processes_ids(pid_t *dst, uint32_t dst_size, uint32_t *written) SA_EXPORT SA_NONNULL
pid_t parent_pid
The id of its parent.
Definition: process.h:89
It has completed execution but still has an entry in the process table.
Definition: process.h:38
char cmdline[SA_PROCESS_CMDLINE]
The command executed to launch this process.
Definition: process.h:86
uid_t uid
The id of the user running this process.
Definition: process.h:77
pid_t sid
Session id of this process.
Definition: process.h:95
The process is traced or stopped.
Definition: process.h:39