2010-10-17 23:50:55 +04:00
|
|
|
|
|
|
|
int cmd_ps(char param[])
|
|
|
|
{
|
|
|
|
|
2017-01-06 19:12:57 +03:00
|
|
|
int i, n, sel;
|
2010-10-17 23:50:55 +04:00
|
|
|
char *buf1k;
|
|
|
|
unsigned PID;
|
|
|
|
short STATE;
|
|
|
|
|
|
|
|
buf1k = malloc(1024);
|
|
|
|
if (NULL == buf1k)
|
|
|
|
return FALSE;
|
|
|
|
|
2017-01-06 19:12:57 +03:00
|
|
|
sel = param && strlen(param) > 0;
|
|
|
|
|
2017-09-27 21:44:15 +03:00
|
|
|
printf (" PID NAME RAM KB\n\r", PID, buf1k+10);
|
|
|
|
|
2010-10-17 23:50:55 +04:00
|
|
|
for (i = 1;;i++)
|
|
|
|
{
|
|
|
|
n = kol_process_info(i, buf1k);
|
2012-03-23 22:53:16 +04:00
|
|
|
PID = *(buf1k+30);
|
|
|
|
STATE = *(buf1k+50);
|
2017-01-06 19:12:57 +03:00
|
|
|
if (9 != STATE)
|
|
|
|
{
|
|
|
|
if (!sel || 0 == strnicmp(param, buf1k+10, 10))
|
|
|
|
{
|
2017-09-27 21:44:15 +03:00
|
|
|
printf (" %7d %11s %d\n\r", PID, buf1k+10, (*(int*)(buf1k+26)+1)/1024);
|
2017-01-06 19:12:57 +03:00
|
|
|
if (sel)
|
|
|
|
{
|
|
|
|
LAST_PID = PID;
|
|
|
|
int cpu_tck = kol_system_cpufreq() / 100;
|
|
|
|
printf (" CPU %d%% RAM %d\n\r", *(int*)buf1k / cpu_tck , *(int*)(buf1k+26)+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-17 23:50:55 +04:00
|
|
|
if (i == n)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(buf1k);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
2013-02-17 19:22:51 +04:00
|
|
|
|