00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SA_PROCESS
00022 #warning You should not include this file directly from your program.
00023 #endif
00024
00029 #ifndef SA_COMMON_PROCESS_H_
00030 #define SA_COMMON_PROCESS_H_
00031
00035 SA_EXPORT enum sa_process_state {
00036 RUNNING = 0,
00037 SLEEPING = 1,
00038 SLEEPING_UNINTERRUPTIBLE = 2,
00039 ZOMBIE = 3,
00040 STOPPED = 4,
00042 };
00043
00047 SA_EXPORT struct sa_process {
00048 #ifdef SA_PROCESS_PID
00049 pid_t pid;
00050 #endif
00051 #ifdef SA_PROCESS_UID
00052 uid_t uid;
00053 #endif
00054 #ifdef SA_PROCESS_GID
00055 gid_t gid;
00056 #endif
00057 #ifdef SA_PROCESS_FILENAME
00058 char filename[SA_PROCESS_FILENAME];
00059 #endif
00060 #ifdef SA_PROCESS_CMDLINE
00061 char cmdline[SA_PROCESS_CMDLINE];
00062 #endif
00063 #ifdef SA_PROCESS_STATE
00064 enum sa_process_state state;
00065 #endif
00066 #ifdef SA_PROCESS_PARENT_PID
00067 pid_t parent_pid;
00068 #endif
00069 #ifdef SA_PROCESS_PGRP
00070 pid_t pgrp;
00071 #endif
00072 #ifdef SA_PROCESS_SID
00073 pid_t sid;
00074 #endif
00075 #ifdef SA_PROCESS_TTY
00076 pid_t tty;
00077 #endif
00078 #ifdef SA_PROCESS_USER_TIME // TODO Explain these better
00079 uint64_t user_time;
00080 #endif
00081 #ifdef SA_PROCESS_SYS_TIME
00082 uint64_t sys_time;
00083 #endif
00084 #ifdef SA_PROCESS_NICE
00085 int8_t nice;
00086 #endif
00087 #ifdef SA_PROCESS_THREADS
00088 uint32_t threads;
00089 #endif
00090 #ifdef SA_PROCESS_START_TIME
00091 uint64_t start_time;
00092 #endif
00093 #ifdef SA_PROCESS_VM_SIZE
00094 uint32_t vm_size;
00095 #endif
00096 #ifdef SA_PROCESS_RSS
00097 uint32_t rss;
00098 #endif
00099 };
00100
00101 #ifdef SA_OPEN_PROCESS
00102
00107 SA_EXPORT int sa_open_process();
00108 #endif
00109
00110 #ifdef SA_CLOSE_PROCESS
00111
00116 SA_EXPORT int sa_close_process();
00117 #endif
00118
00124 SA_EXPORT int sa_count_processes(pid_t* number);
00125
00134 SA_EXPORT int sa_get_processes_ids(pid_t* dst, pid_t dst_size, pid_t* written);
00135
00142 SA_EXPORT int sa_get_process(pid_t pid, struct sa_process* dst);
00143
00151 SA_EXPORT int sa_get_processes(struct sa_process* dst, pid_t dst_size, pid_t* written);
00152
00154 #endif