[comp.sys.hp] HP-UX kernel wizard advice sought...

tml@hemuli.atk.vtt.fi (Tor Lillqvist) (09/05/89)

I am porting the sps program (an improved ps) to HP-UX 3.1 on the
s800.  After some looking through header files, educated guessing and
peeking in the kernel with adb, I have managed to get output like
this:

Ty User     Status Fl Nice Virtual Resident %M  Time Child %C Proc# Command
   root     RUNOUT U         0        0      0   9.1        0     0 Unix Swappe
   root     1A8129          66+ 92   52+ 62  0  29.0+157 M  0     1 (init)
   root     CHILD  U      4096        0      0   0.0        0     2 Unix Pager
   root     LBOLT  U         0        0      0  23.3        0     3 ()
   root     1B58A8 U         0        0      0  25 M        3     4 (netisr)
   root     1A85CC          16+  8    8+  6  0 229.7        0    35 (syncer)
   root     RPIPE          110+ 90   82+ 70  0  26.2+ 24 M  0    39 (cron)
   root     109364          92+ 74   52+ 70  0   0.0        0    42 (netlogstar
   root     ACCEPT          24+ 22   16+ 20  0   0.0        0    54 (rlbdaemon)
   root     RSOCKT          36+ 52   24+ 46  0   0.0             57 (sockregd)
   root     SELECT          48+ 64   34+ 54  0   5.6        0    62 (portmap)
   root     RSOCKT          38+ 48   26+ 46  0  12.2        0    65 (nfsd)
    |       RSOCKT          38+ 48   26+ 46  0  13.3        0    69 (nfsd)
   root     async            0        0      0                   70 ** No upage
   root     SELECT         106+118   78+112  1  17.6+ 21 M  0    85 (inetd)
    *       SELECT          44+ 62   32+ 60  0  44.1        0   893 (rlogind)
p0.  *tjs   RTTYP0          98+168   82+124  0   9.0+306.0  0   894 (ksh)
   root     SELECT          52+ 70   34+ 68  0   5.1        0    96 (syslogd)
   root     RSOCKT         140+ 60  130+ 54  0  14 M        0    99 (rwhod)
   root     SELECT         138+138  110+122  1   3.1        0   102 (named)
   root     ACCEPT         238+172  226+166  1  14.3+ 20.7  0   106 (sendmail)
   root     MSG            134+ 48  120+ 46  0   1.0        0   109 (adjtimed)
   root     ACCEPT          32+ 30   14+ 28  0   1.3+ 75.0  0   122 (nftdaemon)
   root     1C63C0  I      124+ 40  116+ 38  0   0.0            147 (delog)
   root     RTTY02          42+ 48   26+ 46  0   0.1        0   158 (getty)
14 root     RTTY10          42+ 48   26+ 46  0   0.1        0   160 (getty)
   root     rtty13          42+ 48    0+ 46  0   0.1        0   164 ()
   tml      SELECT         302+250  290+222  1  22.5        0   851 (xload)
   tml      SELECT         244+368  234+338  1 106.6        0  1226 (xterm)
r8. *       RTTYR8          92+168   80+124  0  16.4+ 41 M  0  1229 (ksh)
p0 vdx      MSG             70+206   60+170  1   2.2        0  1681 (master)
p0  |       MSG             80+220   64+134  1   1.0        0  1728 (users)
     *      1AC163         240+774  132+462  1   5.5        0  1729 (hpimage)
137 (40710k) processes, 3 (400k) busy, 129 (29174k) loaded, 8 (104k) swapped

(Only a part of the lines from sps -va included above.)

(Earlier, while porting the top program, I have asked for (and
received) advice how to find the user area of a process on the s800,
thanks to mck@hpdstma.)

There are still some glitches in the output, so I have a few
questions:

- What is the best way to get at the process argument vector and
  environment strings in HP-UX on the s800?  The command name you see
  above is from u_comm in the u area, but sps wants to print all the
  argv strings (and even the environment with an option).  The code
  for VAXen and Suns in sps is a bit cryptic, playing with ptes etc.
  Some example code would be a great...

- How do you mangle the argv strings in a program to change what shows
  up in ps -f.  Sendmail and ftpd want to do this.  (And some
  games...)

- What kernel varaible or table entry is a process waiting on when in
  a sleep system call?  I guess that for instance "syncer" above is
  doing a sleep.  What about pause?  (I guess that is what the
  "hpimage" processes do when idle).  Sps prints the wchan in hex
  (which doesn't fit into six columns) if it can't figure out what it
  refers to.
-- 
Tor Lillqvist
Technical Research Centre of Finland, Computing Services (VTT/ATK)
tml@hemuli.atk.vtt.fi [130.188.52.2]