How to get 'SIZE' and 'RES' when running TOP in C?

How to get 'SIZE' and 'RES' when running TOP in C?

Post by DDB » Thu, 15 Apr 1999 04:00:00



When I use "top", information will be shown like below...
==============================================================
2 processes:   1 sleeping, 1 on cpu
Cpu states:  0.0% idle,  100% user,  0.0% kernel,  0.0% iowait,  0.0%
swap
Memory: 30M real, 10M free, 11M swap, 114M free swap

  PID USERNAME PRI NICE  SIZE    RES     STATE   TIME   WCPU    CPU
COMMAND
 3497 xxxxxxxxx      27    0        1360K 1232K cpu         0:00
0.00%      0.00% top
 3428 xxxxxxxxx      33    0        1168K 1040K sleep       0:00
0.00%      0.00% csh
==============================================================

How can I determine the information in column "SIZE" and "RES" in C
Program?

 
 
 

How to get 'SIZE' and 'RES' when running TOP in C?

Post by Casper H.S. Dik - Network Security Engine » Thu, 15 Apr 1999 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>How can I determine the information in column "SIZE" and "RES" in C
>Program?

Well, since you have top you probably have top source.

Read it.  (check ftp.groupsys.com: ...)

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

1. Problem in getting screen size when 'rlogin' and 'telnet'

Hi,
        I have a problem in getting screen size using "ioctl" function.

        The following program returns the correct screen size if the term is
by "rlogin" but does return an error if term is by "telnet".

#include<stdio.h>
#include<termios.h>
#include<unistd.h>
extern int errno;
main()
{
   struct winsize ws;

   if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
        printf("%d is the errno\n", errno);

   printf("%d is the width\n", ws.ws_col);
   printf("%d is the length\n", ws.ws_row);

The output for the above program from an "rlogin" window is
90 is the width
58 is the length

The output from a "telnet" window is
22 is the errno
0 is the width
0 is the length

Could anybody educate me regarding this?

        Also "stty" behaves differently from "rlogin" window and from a "telnet"
window.
        The command "stty rows 24" works Okay on an "rlogin" terminal
but, on a "telnet" terminal it gives the following error:
        unknown mode: rows

Could anybody help me in this regard? Please send me email.

Thanks

vasant

2. Sunscreen 3.2 / Stateful UDP

3. Limiting 'w', 'top' and 'ps'

4. adduser gives bad GID err

5. What does 'res' mean in output of TOP command

6. How to setup up console text in color?

7. What's 'side effects' of Ksh built-ins?

8. HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

9. 'top' output -> High CPU consumption when thread is in 'sleep' state

10. SIGFPE with 'top' or 'ps -u' -- why ???

11. Has anyone ported 'top' or 'sps' to AIX ?

12. difference between 'buff' and 'cached' in top + free + /proc/memstat

13. should I trust 'free' or 'top'?