- if (curstatus.rss == 0 && curstatus.state[0] != 'Z')
- curstatus.state[1] = 'W';
- else
- curstatus.state[1] = ' ';
- if (tasknice < 0)
- curstatus.state[2] = '<';
- else if (tasknice > 0)
- curstatus.state[2] = 'N';
- else
- curstatus.state[2] = ' ';
-
-#ifdef PAGE_SHIFT
- curstatus.rss <<= (PAGE_SHIFT - 10); /* 2**10 = 1kb */
+ /* see proc(5) for some details on this */
+ strcpy(filename_tail, "/stat");
+ n = read_to_buf(filename, buf);
+ if (n < 0)
+ break;
+ cp = strrchr(buf, ')'); /* split into "PID (cmd" and "<rest>" */
+ /*if (!cp || cp[1] != ' ')
+ break;*/
+ cp[0] = '\0';
+ if (sizeof(sp->comm) < 16)
+ BUG_comm_size();
+ comm1 = strchr(buf, '(');
+ /*if (comm1)*/
+ safe_strncpy(sp->comm, comm1 + 1, sizeof(sp->comm));
+
+#if !ENABLE_FEATURE_FAST_TOP
+ n = sscanf(cp+2,
+ "%c %u " /* state, ppid */
+ "%u %u %d %*s " /* pgid, sid, tty, tpgid */
+ "%*s %*s %*s %*s %*s " /* flags, min_flt, cmin_flt, maj_flt, cmaj_flt */
+ "%lu %lu " /* utime, stime */
+ "%*s %*s %*s " /* cutime, cstime, priority */
+ "%ld " /* nice */
+ "%*s %*s " /* timeout, it_real_value */
+ "%lu " /* start_time */
+ "%lu " /* vsize */
+ "%lu " /* rss */
+ /* "%lu %lu %lu %lu %lu %lu " rss_rlim, start_code, end_code, start_stack, kstk_esp, kstk_eip */
+ /* "%u %u %u %u " signal, blocked, sigignore, sigcatch */
+ /* "%lu %lu %lu" wchan, nswap, cnswap */
+ ,
+ sp->state, &sp->ppid,
+ &sp->pgid, &sp->sid, &tty,
+ &sp->utime, &sp->stime,
+ &tasknice,
+ &sp->start_time,
+ &vsz,
+ &rss);
+ if (n != 11)
+ break;
+ /* vsz is in bytes and we want kb */
+ sp->vsz = vsz >> 10;
+ /* vsz is in bytes but rss is in *PAGES*! Can you believe that? */
+ sp->rss = rss << sp->shift_pages_to_kb;
+ sp->tty_major = (tty >> 8) & 0xfff;
+ sp->tty_minor = (tty & 0xff) | ((tty >> 12) & 0xfff00);