2006-06-06 20:28:42 +00:00
|
|
|
/* Do not edit this file. It was automatically generated. */
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#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"
|
2008-03-09 02:33:23 +00:00
|
|
|
#include "RichString.h"
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#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>
|
2007-11-08 23:23:01 +00:00
|
|
|
#include <sched.h>
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2009-03-11 13:15:43 +00:00
|
|
|
#ifdef HAVE_PLPA
|
2008-03-05 09:46:47 +00:00
|
|
|
#include <plpa.h>
|
2009-03-11 13:15:43 +00:00
|
|
|
#endif
|
2008-03-05 09:46:47 +00:00
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
// This works only with glibc 2.1+. On earlier versions
|
|
|
|
// the behavior is similar to have a hardcoded page size.
|
2007-05-17 18:29:30 +00:00
|
|
|
#ifndef PAGE_SIZE
|
2009-03-11 13:15:43 +00:00
|
|
|
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
|
2007-05-17 18:29:30 +00:00
|
|
|
#endif
|
2009-03-11 13:15:43 +00:00
|
|
|
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#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,
|
2007-11-08 23:23:01 +00:00
|
|
|
USER, TIME, NLWP, TGID,
|
2007-08-10 05:07:14 +00:00
|
|
|
#ifdef HAVE_OPENVZ
|
2009-03-11 13:05:19 +00:00
|
|
|
CTID, VPID,
|
2007-08-10 05:07:14 +00:00
|
|
|
#endif
|
2008-09-23 04:31:13 +00:00
|
|
|
#ifdef HAVE_VSERVER
|
|
|
|
VXID,
|
|
|
|
#endif
|
2008-03-09 08:02:22 +00:00
|
|
|
#ifdef HAVE_TASKSTATS
|
2008-03-14 18:50:49 +00:00
|
|
|
RCHAR, WCHAR, SYSCR, SYSCW, RBYTES, WBYTES, CNCLWB, IO_READ_RATE, IO_WRITE_RATE, IO_RATE,
|
2008-03-09 08:02:22 +00:00
|
|
|
#endif
|
2007-08-10 05:07:14 +00:00
|
|
|
LAST_PROCESSFIELD
|
2006-03-04 18:16:49 +00:00
|
|
|
} ProcessField;
|
|
|
|
|
|
|
|
struct ProcessList_;
|
|
|
|
|
|
|
|
typedef struct Process_ {
|
|
|
|
Object super;
|
|
|
|
|
|
|
|
struct ProcessList_ *pl;
|
|
|
|
bool updated;
|
|
|
|
|
2007-05-17 18:29:30 +00:00
|
|
|
unsigned int pid;
|
2006-03-04 18:16:49 +00:00
|
|
|
char* comm;
|
|
|
|
int indent;
|
|
|
|
char state;
|
|
|
|
bool tag;
|
2007-05-17 18:29:30 +00:00
|
|
|
unsigned int ppid;
|
|
|
|
unsigned int pgrp;
|
|
|
|
unsigned int session;
|
|
|
|
unsigned int tty_nr;
|
2007-11-08 23:23:01 +00:00
|
|
|
unsigned int tgid;
|
|
|
|
int tpgid;
|
2006-03-04 18:16:49 +00:00
|
|
|
unsigned long int flags;
|
2006-07-11 06:13:32 +00:00
|
|
|
#ifdef DEBUG
|
2006-03-04 18:16:49 +00:00
|
|
|
unsigned long int minflt;
|
|
|
|
unsigned long int cminflt;
|
|
|
|
unsigned long int majflt;
|
|
|
|
unsigned long int cmajflt;
|
2006-07-11 06:13:32 +00:00
|
|
|
#endif
|
2006-03-04 18:16:49 +00:00
|
|
|
unsigned long int utime;
|
|
|
|
unsigned long int stime;
|
|
|
|
long int cutime;
|
|
|
|
long int cstime;
|
|
|
|
long int priority;
|
|
|
|
long int nice;
|
2007-05-21 19:10:53 +00:00
|
|
|
long int nlwp;
|
2006-07-11 06:13:32 +00:00
|
|
|
#ifdef DEBUG
|
2006-03-04 18:16:49 +00:00
|
|
|
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;
|
2006-07-11 06:13:32 +00:00
|
|
|
#endif
|
2006-03-04 18:16:49 +00:00
|
|
|
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;
|
2006-07-12 01:35:59 +00:00
|
|
|
char* user;
|
2007-08-10 05:07:14 +00:00
|
|
|
#ifdef HAVE_OPENVZ
|
2009-03-11 13:05:19 +00:00
|
|
|
unsigned int ctid;
|
2007-08-10 05:07:14 +00:00
|
|
|
unsigned int vpid;
|
|
|
|
#endif
|
2008-09-23 04:31:13 +00:00
|
|
|
#ifdef HAVE_VSERVER
|
|
|
|
unsigned int vxid;
|
|
|
|
#endif
|
2008-03-09 08:02:22 +00:00
|
|
|
#ifdef HAVE_TASKSTATS
|
|
|
|
unsigned long long io_rchar;
|
|
|
|
unsigned long long io_wchar;
|
|
|
|
unsigned long long io_syscr;
|
|
|
|
unsigned long long io_syscw;
|
|
|
|
unsigned long long io_read_bytes;
|
|
|
|
unsigned long long io_write_bytes;
|
|
|
|
unsigned long long io_cancelled_write_bytes;
|
|
|
|
double io_rate_read_bps;
|
|
|
|
unsigned long long io_rate_read_time;
|
|
|
|
double io_rate_write_bps;
|
|
|
|
unsigned long long io_rate_write_time;
|
|
|
|
#endif
|
2006-03-04 18:16:49 +00:00
|
|
|
} Process;
|
|
|
|
|
|
|
|
|
2006-07-11 06:13:32 +00:00
|
|
|
#ifdef DEBUG
|
2006-06-06 20:28:42 +00:00
|
|
|
extern char* PROCESS_CLASS;
|
2006-07-11 06:13:32 +00:00
|
|
|
#else
|
|
|
|
#define PROCESS_CLASS NULL
|
|
|
|
#endif
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2006-06-06 20:28:42 +00:00
|
|
|
extern char *Process_fieldNames[];
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2008-03-14 18:50:49 +00:00
|
|
|
extern char *Process_fieldTitles[];
|
|
|
|
|
2008-03-09 08:58:38 +00:00
|
|
|
#define ONE_K 1024
|
|
|
|
#define ONE_M (ONE_K * ONE_K)
|
|
|
|
#define ONE_G (ONE_M * ONE_K)
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
void Process_delete(Object* cast);
|
|
|
|
|
2008-03-09 08:58:38 +00:00
|
|
|
Process* Process_new(struct ProcessList_ *pl);
|
|
|
|
|
|
|
|
Process* Process_clone(Process* this);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
void Process_toggleTag(Process* this);
|
|
|
|
|
2007-12-17 05:57:28 +00:00
|
|
|
bool Process_setPriority(Process* this, int priority);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2009-03-11 13:15:43 +00:00
|
|
|
#ifdef HAVE_PLPA
|
2007-11-08 23:23:01 +00:00
|
|
|
unsigned long Process_getAffinity(Process* this);
|
|
|
|
|
2007-12-17 05:57:28 +00:00
|
|
|
bool Process_setAffinity(Process* this, unsigned long mask);
|
2009-03-11 13:15:43 +00:00
|
|
|
#endif
|
2007-11-08 23:23:01 +00:00
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
void Process_sendSignal(Process* this, int signal);
|
|
|
|
|
2006-07-11 06:13:32 +00:00
|
|
|
int Process_pidCompare(const void* v1, const void* v2);
|
|
|
|
|
|
|
|
int Process_compare(const void* v1, const void* v2);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#endif
|