procs: sttates
This commit is contained in:
parent
f575ded300
commit
325216853d
|
@ -65,40 +65,48 @@ struct _States
|
||||||
const char *name;
|
const char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const States _states[] =
|
static const char * _states[255];
|
||||||
|
|
||||||
|
static void
|
||||||
|
_states_init(void)
|
||||||
{
|
{
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
{ 'd', "dsleep" },
|
_states['D'] = "dsleep";
|
||||||
{ 'i', "idle" },
|
_states['I'] = "idle";
|
||||||
{ 'r', "run" },
|
_states['R'] = "run";
|
||||||
{ 's', "sleep" },
|
_states['S'] = "sleep";
|
||||||
{ 't', "stop" },
|
_states['T'] = "stop";
|
||||||
{ 'x', "dead" },
|
_states['X'] = "dead";
|
||||||
{ 'z', "zombie" },
|
_states['Z'] = "zombie";
|
||||||
#else
|
#else
|
||||||
{ SIDL, "idle"},
|
_states[SIDL] = "idle";
|
||||||
{ SRUN, "run" },
|
_states[SRUN] = "run";,
|
||||||
{ SSLEEP, "sleep" },
|
_states[SSLEEP] = "sleep";
|
||||||
{ SSTOP, "stop" },
|
_states[SSTOP] = "stop";
|
||||||
#if !defined(__MacOS__)
|
#if !defined(__MacOS__)
|
||||||
#if !defined(__OpenBSD__)
|
#if !defined(__OpenBSD__)
|
||||||
{ SWAIT, "wait" },
|
_states[SWAIT] = "wait";
|
||||||
{ SLOCK, "lock" },
|
_states[SLOCK] = "lock";,
|
||||||
{ SZOMB, "zombie" },
|
_states[SZOMB] = "zombie";
|
||||||
#endif
|
#endif
|
||||||
#if defined(__OpenBSD__)
|
#if defined(__OpenBSD__)
|
||||||
{ SDEAD, "dead" },
|
_states[SDEAD] = "dead";
|
||||||
{ SONPROC, "onproc"},
|
_states[SONPROC] = "onproc"};
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
_process_state_name(char state)
|
_process_state_name(char state)
|
||||||
{
|
{
|
||||||
return _states[tolower(state)].name;
|
static int init = 0;
|
||||||
|
if (!init)
|
||||||
|
{
|
||||||
|
_states_init();
|
||||||
|
init = 1;
|
||||||
|
}
|
||||||
|
return _states[toupper(state)];
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
@ -298,6 +306,7 @@ static Eina_List *
|
||||||
_process_list_linux_get(void)
|
_process_list_linux_get(void)
|
||||||
{
|
{
|
||||||
Eina_List *files, *list;
|
Eina_List *files, *list;
|
||||||
|
const char *state;
|
||||||
char *n;
|
char *n;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
Stat st;
|
Stat st;
|
||||||
|
@ -328,7 +337,7 @@ _process_list_linux_get(void)
|
||||||
p->cpu_id = st.psr;
|
p->cpu_id = st.psr;
|
||||||
p->start = st.start_time;
|
p->start = st.start_time;
|
||||||
p->run_time = st.run_time;
|
p->run_time = st.run_time;
|
||||||
state = _process_state_name(kp->ki_stat);
|
state = _process_state_name(st.state);
|
||||||
snprintf(p->state, sizeof(p->state), "%s", state);
|
snprintf(p->state, sizeof(p->state), "%s", state);
|
||||||
p->cpu_time = st.utime + st.stime;
|
p->cpu_time = st.utime + st.stime;
|
||||||
p->nice = st.nice;
|
p->nice = st.nice;
|
||||||
|
@ -349,6 +358,7 @@ static void
|
||||||
_proc_thread_info(Proc_Info *p)
|
_proc_thread_info(Proc_Info *p)
|
||||||
{
|
{
|
||||||
Eina_List *files;
|
Eina_List *files;
|
||||||
|
const char *state;
|
||||||
char *n;
|
char *n;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
Stat st;
|
Stat st;
|
||||||
|
@ -366,7 +376,8 @@ _proc_thread_info(Proc_Info *p)
|
||||||
Proc_Info *t = calloc(1, sizeof(Proc_Info));
|
Proc_Info *t = calloc(1, sizeof(Proc_Info));
|
||||||
if (!t) continue;
|
if (!t) continue;
|
||||||
t->cpu_id = st.psr;
|
t->cpu_id = st.psr;
|
||||||
t->state = _process_state_name(st.state);
|
state = _process_state_name(st.state);
|
||||||
|
snprintf(t->state, sizeof(t->state), "%s", state);
|
||||||
t->cpu_time = st.utime + st.stime;
|
t->cpu_time = st.utime + st.stime;
|
||||||
t->nice = st.nice;
|
t->nice = st.nice;
|
||||||
t->priority = st.pri;
|
t->priority = st.pri;
|
||||||
|
|
Loading…
Reference in New Issue