home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / sps3 / part01 < prev    next >
Encoding:
Text File  |  1992-05-08  |  65.8 KB  |  2,262 lines

  1. Newsgroups: comp.sources.unix
  2. From: robert@olsen.ch (Robert Ward)
  3. Subject: v26i024: sps3 - show process status, Part01/03
  4. Sender: unix-sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: robert@olsen.ch (Robert Ward)
  8. Posting-Number: Volume 26, Issue 24
  9. Archive-Name: sps3/part01
  10.  
  11. [ I've been using various versions of "sps" for many years.  It is so much
  12.   better than the "ps" you got with your system (no matter what system), that
  13.   you will wonder how you ever got along without it.  It builds and installs
  14.   trivially on my Ultrix systems, which according to the README are the least
  15.   supported.  In other words, this thing is on greased skids.  Use it!  --vix ]
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 1 (of 3)."
  24. # Contents:  BUG-libkvm MANIFEST Makefile.4.1 Makefile.4.2 Makefile.4.3
  25. #   Makefile.4.3+NFS Makefile.sun.2.0 Makefile.sun.3.0
  26. #   Makefile.sun.3.2 Makefile.sun.4.0 Makefile.sun.4.0+386i
  27. #   Makefile.sun.4.1 Makefile.sun4.3.2 Makefile.ultrix.2.0
  28. #   Makefile.ultrix.3.0 Makefile.ultrix.4.0 README RELEASENOTES
  29. #   filecount.c findtty.c flags.h flagsetup.c globals1.c hashuid.c
  30. #   initialise.c mktree.c percentmem.c prcmd.c prcpu.c prheader.c
  31. #   printall.c prsummary.c readstatus.c selectproc.c selecttty.c
  32. #   termwidth.c vmstat.c
  33. # Wrapped by vixie@cognition.pa.dec.com on Sat May  9 22:30:50 1992
  34. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  35. if test -f 'BUG-libkvm' -a "${1}" != "-c" ; then 
  36.   echo shar: Will not clobber existing file \"'BUG-libkvm'\"
  37. else
  38. echo shar: Extracting \"'BUG-libkvm'\" \(1656 characters\)
  39. sed "s/^X//" >'BUG-libkvm' <<'END_OF_FILE'
  40. There is a bug in kvm_getcmd(3) which occurs when the arguments for a command
  41. contain an '=', or if an '=' in the environment is removed.  In user space,
  42. command arguments are laid out like this:
  43. X
  44. a r g 0 '\0' a r g 1 '\0' ... e n v 1 = e n v '\0' e n v 2 = e n v ...
  45. X
  46. The only way to tell where the arguments end and the environment begins is to
  47. look for arguments which contain '=', or environment strings which don't.  Most
  48. programs used to use the first approach.  The libkvm library uses the latter,
  49. and gets it wrong if it sees a '=' in any strings before the last string
  50. which doesn't have one.  The korn shell nulls out some '=' in it's environment,
  51. and if you have it, it's the most noticable tickler of this bug.  But even if
  52. you don't, you can tickle it with "vi a=b c".
  53. X
  54. Here's the fix.  You could probably patch the binary to ignore the
  55. X"&& (argd.cnt == 0)" test, which will cause slightly incorrect results,
  56. but ones a bit closer to the truth.  Just search for "\0=" in the
  57. library, and look past it a bit.
  58. X
  59. X*** /tmp/,RCSt1a01687    Wed Sep 28 01:50:36 1988
  60. X--- kvmgetcmd.c    Mon Aug 29 23:23:43 1988
  61. X***************
  62. X*** 141,150 ****
  63. X              if (*cp == '=')
  64. X                  eqseen++;
  65. X              if (*cp-- == '\0') {
  66. X!                 if (eqseen && (argd.cnt == 0)) {
  67. X                      envd.cnt++;
  68. X                      envd.sp = Uvaddr(cp+2);
  69. X                      eqseen = 0;
  70. X                  } else {
  71. X                      argd.cnt++;
  72. X                  }
  73. X--- 141,154 ----
  74. X              if (*cp == '=')
  75. X                  eqseen++;
  76. X              if (*cp-- == '\0') {
  77. X!                 if (eqseen) {
  78. X                      envd.cnt++;
  79. X                      envd.sp = Uvaddr(cp+2);
  80. X                      eqseen = 0;
  81. X+                     if (argd.cnt != 0) {
  82. X+                         envd.cnt += argd.cnt;
  83. X+                         argd.cnt = 0;
  84. X+                     }
  85. X                  } else {
  86. X                      argd.cnt++;
  87. X                  }
  88. END_OF_FILE
  89. if test 1656 -ne `wc -c <'BUG-libkvm'`; then
  90.     echo shar: \"'BUG-libkvm'\" unpacked with wrong size!
  91. fi
  92. # end of 'BUG-libkvm'
  93. fi
  94. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  95.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  96. else
  97. echo shar: Extracting \"'MANIFEST'\" \(1708 characters\)
  98. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  99. X   File Name        Archive #    Description
  100. X-----------------------------------------------------------
  101. X BUG-libkvm                 1    
  102. X MANIFEST                   1    
  103. X Makefile.4.1               1    
  104. X Makefile.4.2               1    
  105. X Makefile.4.3               1    
  106. X Makefile.4.3+NFS           1    
  107. X Makefile.sun.2.0           1    
  108. X Makefile.sun.3.0           1    
  109. X Makefile.sun.3.2           1    
  110. X Makefile.sun.4.0           1    
  111. X Makefile.sun.4.0+386i      1    
  112. X Makefile.sun.4.1           1    
  113. X Makefile.sun4.3.2          1    
  114. X Makefile.ultrix.2.0        1    
  115. X Makefile.ultrix.3.0        1    
  116. X Makefile.ultrix.4.0        1    
  117. X README                     1    
  118. X RELEASENOTES               1    
  119. X filecount.c                1    
  120. X findtty.c                  1    
  121. X flagdecode.c               2    
  122. X flags.h                    1    
  123. X flagsetup.c                1    
  124. X getcmd.c                   3    
  125. X getupage.c                 2    
  126. X globals1.c                 1    
  127. X globals2.c                 2    
  128. X hashuid.c                  1    
  129. X initialise.c               1    
  130. X initsymbols.c              2    
  131. X inittty.c                  2    
  132. X main.c                     2    
  133. X mktree.c                   1    
  134. X needed.c                   2    
  135. X openfiles.c                2    
  136. X percentmem.c               1    
  137. X prcmd.c                    1    
  138. X prcpu.c                    1    
  139. X prheader.c                 1    
  140. X printall.c                 1    
  141. X printproc.c                3    
  142. X prsummary.c                1    
  143. X readstatus.c               1    
  144. X selectproc.c               1    
  145. X selecttty.c                1    
  146. X sps.1                      3    
  147. X sps.h                      2    
  148. X stream.c                   2    
  149. X termwidth.c                1    
  150. X ttystatus.c                2    
  151. X vmstat.c                   1    
  152. X waitingfor.c               3    
  153. END_OF_FILE
  154. if test 1708 -ne `wc -c <'MANIFEST'`; then
  155.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  156. fi
  157. # end of 'MANIFEST'
  158. fi
  159. if test -f 'Makefile.4.1' -a "${1}" != "-c" ; then 
  160.   echo shar: Will not clobber existing file \"'Makefile.4.1'\"
  161. else
  162. echo shar: Extracting \"'Makefile.4.1'\" \(882 characters\)
  163. sed "s/^X//" >'Makefile.4.1' <<'END_OF_FILE'
  164. X# Makefile for SPS (4.1BSD UNIX Version)
  165. X
  166. PROG    =       sps
  167. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  168. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  169. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  170. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  171. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  172. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  173. X
  174. INCS    =       sps.h
  175. LIBS    =       -ltermlib
  176. CFLAGS  =       -I/usr/src/sys -DCHAOS
  177. X
  178. all:            $(PROG)
  179. X.c.o:
  180. X        cc $(CFLAGS) -c -O -R $<
  181. globals1.o waitingfor.o:
  182. X        cc $(CFLAGS) -c -O $<
  183. X
  184. X$(OBJS):        $(INCS)
  185. X
  186. X$(PROG):        $(OBJS)
  187. X        cc -o $@ $(OBJS) $(LIBS)
  188. X
  189. install:        $(PROG)
  190. X        strip $(PROG)
  191. X        mv $(PROG) /bin/$(PROG)
  192. X        /etc/chown root /bin/$(PROG)
  193. X        chmod 4711 /bin/$(PROG)
  194. X
  195. lint:
  196. X        lint -x -b $(CFLAGS) *.c
  197. clean:
  198. X        rm -f $(OBJS) $(PROG)
  199. END_OF_FILE
  200. if test 882 -ne `wc -c <'Makefile.4.1'`; then
  201.     echo shar: \"'Makefile.4.1'\" unpacked with wrong size!
  202. fi
  203. # end of 'Makefile.4.1'
  204. fi
  205. if test -f 'Makefile.4.2' -a "${1}" != "-c" ; then 
  206.   echo shar: Will not clobber existing file \"'Makefile.4.2'\"
  207. else
  208. echo shar: Extracting \"'Makefile.4.2'\" \(977 characters\)
  209. sed "s/^X//" >'Makefile.4.2' <<'END_OF_FILE'
  210. X# Makefile for SPS (Vax 4.2BSD and Ultrix1.2 UNIX Version)
  211. X
  212. PROG    =       sps
  213. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  214. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  215. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  216. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  217. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  218. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  219. INCS    =       sps.h
  220. CC      =       cc
  221. CFLAGS  =       -DBSD42 -I/sys
  222. LIBS    =       -ltermlib
  223. DIRINSTALL =    /bin
  224. X
  225. all:            $(PROG)
  226. X.c.o:
  227. X        $(CC) $(CFLAGS) -c -O -R $<
  228. X    
  229. globals1.o waitingfor.o:
  230. X        $(CC) $(CFLAGS) -c -O $<
  231. X
  232. X$(OBJS):        $(INCS)
  233. X
  234. X$(PROG):        $(OBJS)
  235. X        $(CC) -o $@ $(OBJS) $(LIBS)
  236. X
  237. install:        $(PROG)
  238. X        strip $(PROG)
  239. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  240. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  241. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  242. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  243. X
  244. lint:
  245. X        lint -x -b $(CFLAGS) *.c
  246. clean:
  247. X        rm -f $(OBJS) $(PROG)
  248. END_OF_FILE
  249. if test 977 -ne `wc -c <'Makefile.4.2'`; then
  250.     echo shar: \"'Makefile.4.2'\" unpacked with wrong size!
  251. fi
  252. # end of 'Makefile.4.2'
  253. fi
  254. if test -f 'Makefile.4.3' -a "${1}" != "-c" ; then 
  255.   echo shar: Will not clobber existing file \"'Makefile.4.3'\"
  256. else
  257. echo shar: Extracting \"'Makefile.4.3'\" \(966 characters\)
  258. sed "s/^X//" >'Makefile.4.3' <<'END_OF_FILE'
  259. X# Makefile for SPS (Vax 4.3BSD Version)
  260. X
  261. PROG    =       sps
  262. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  263. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  264. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  265. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  266. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  267. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  268. INCS    =       sps.h
  269. CC      =       cc
  270. CFLAGS  =       -DBSD42 -DBSD43 -I/sys
  271. LIBS    =       -ltermlib
  272. DIRINSTALL =    /bin
  273. X
  274. all:            $(PROG)
  275. X.c.o:
  276. X        $(CC) $(CFLAGS) -c -O -R $<
  277. X    
  278. globals1.o waitingfor.o:
  279. X        $(CC) $(CFLAGS) -c -O $<
  280. X
  281. X$(OBJS):        $(INCS)
  282. X
  283. X$(PROG):        $(OBJS)
  284. X        $(CC) -o $@ $(OBJS) $(LIBS)
  285. X
  286. install:        $(PROG)
  287. X        strip $(PROG)
  288. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  289. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  290. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  291. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  292. X
  293. lint:
  294. X        lint -x -b $(CFLAGS) *.c
  295. clean:
  296. X        rm -f $(OBJS) $(PROG)
  297. END_OF_FILE
  298. if test 966 -ne `wc -c <'Makefile.4.3'`; then
  299.     echo shar: \"'Makefile.4.3'\" unpacked with wrong size!
  300. fi
  301. # end of 'Makefile.4.3'
  302. fi
  303. if test -f 'Makefile.4.3+NFS' -a "${1}" != "-c" ; then 
  304.   echo shar: Will not clobber existing file \"'Makefile.4.3+NFS'\"
  305. else
  306. echo shar: Extracting \"'Makefile.4.3+NFS'\" \(976 characters\)
  307. sed "s/^X//" >'Makefile.4.3+NFS' <<'END_OF_FILE'
  308. X# Makefile for SPS (Vax 4.3BSD+NFS Version)
  309. X
  310. PROG    =       sps
  311. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  312. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  313. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  314. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  315. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  316. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  317. INCS    =       sps.h
  318. CC      =       cc
  319. CFLAGS  =       -DBSD42 -DBSD43 -DNFS -I/sys
  320. LIBS    =       -ltermlib
  321. DIRINSTALL =    /bin
  322. X
  323. all:            $(PROG)
  324. X.c.o:
  325. X        $(CC) $(CFLAGS) -c -O -R $<
  326. X    
  327. globals1.o waitingfor.o:
  328. X        $(CC) $(CFLAGS) -c -O $<
  329. X
  330. X$(OBJS):        $(INCS)
  331. X
  332. X$(PROG):        $(OBJS)
  333. X        $(CC) -o $@ $(OBJS) $(LIBS)
  334. X
  335. install:        $(PROG)
  336. X        strip $(PROG)
  337. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  338. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  339. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  340. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  341. X
  342. lint:
  343. X        lint -x -b $(CFLAGS) *.c
  344. clean:
  345. X        rm -f $(OBJS) $(PROG)
  346. END_OF_FILE
  347. if test 976 -ne `wc -c <'Makefile.4.3+NFS'`; then
  348.     echo shar: \"'Makefile.4.3+NFS'\" unpacked with wrong size!
  349. fi
  350. # end of 'Makefile.4.3+NFS'
  351. fi
  352. if test -f 'Makefile.sun.2.0' -a "${1}" != "-c" ; then 
  353.   echo shar: Will not clobber existing file \"'Makefile.sun.2.0'\"
  354. else
  355. echo shar: Extracting \"'Makefile.sun.2.0'\" \(1009 characters\)
  356. sed "s/^X//" >'Makefile.sun.2.0' <<'END_OF_FILE'
  357. X# Makefile for SPS (Sun-2, Sun UNIX 4.2 Release 2.x Version)
  358. X
  359. PROG    =       sps
  360. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  361. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  362. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  363. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  364. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  365. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  366. INCS    =       sps.h
  367. CC      =       cc
  368. CFLAGS  =       -DSUN -DBSD42 -DNFS -DNOQUOTA -I/sys
  369. LIBS    =       -ltermlib
  370. DIRINSTALL    = /bin
  371. X
  372. all:            $(PROG)
  373. X.c.o:
  374. X        $(CC) $(CFLAGS) -c -O -R $<
  375. X    
  376. globals1.o waitingfor.o:
  377. X        $(CC) $(CFLAGS) -c -O $<
  378. X
  379. X$(OBJS):        $(INCS)
  380. X
  381. X$(PROG):        $(OBJS)
  382. X        $(CC) -o $@ $(OBJS) $(LIBS)
  383. X
  384. install:        $(PROG)
  385. X        strip $(PROG)
  386. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  387. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  388. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  389. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  390. X
  391. lint:
  392. X        lint -x -b $(CFLAGS) *.c $(LIBS)
  393. clean:
  394. X        rm -f $(OBJS) $(PROG)
  395. END_OF_FILE
  396. if test 1009 -ne `wc -c <'Makefile.sun.2.0'`; then
  397.     echo shar: \"'Makefile.sun.2.0'\" unpacked with wrong size!
  398. fi
  399. # end of 'Makefile.sun.2.0'
  400. fi
  401. if test -f 'Makefile.sun.3.0' -a "${1}" != "-c" ; then 
  402.   echo shar: Will not clobber existing file \"'Makefile.sun.3.0'\"
  403. else
  404. echo shar: Extracting \"'Makefile.sun.3.0'\" \(1009 characters\)
  405. sed "s/^X//" >'Makefile.sun.3.0' <<'END_OF_FILE'
  406. X# Makefile for SPS (Sun-2 and Sun-3, Sun UNIX 4.2 Release 3.0 Version)
  407. X
  408. PROG    =       sps
  409. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  410. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  411. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  412. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  413. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  414. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  415. INCS    =       sps.h
  416. CC      =       cc
  417. CFLAGS  =       -DSUN -DBSD42 -DNFS -I/sys
  418. LIBS    =       -ltermlib
  419. DIRINSTALL    = /bin
  420. X
  421. all:            $(PROG)
  422. X.c.o:
  423. X        $(CC) $(CFLAGS) -c -O -R $<
  424. X    
  425. globals1.o waitingfor.o:
  426. X        $(CC) $(CFLAGS) -c -O $<
  427. X
  428. X$(OBJS):        $(INCS)
  429. X
  430. X$(PROG):        $(OBJS)
  431. X        $(CC) -o $@ $(OBJS) $(LIBS)
  432. X
  433. install:        $(PROG)
  434. X        strip $(PROG)
  435. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  436. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  437. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  438. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  439. X
  440. lint:
  441. X        lint -x -b $(CFLAGS) *.c $(LIBS)
  442. clean:
  443. X        rm -f $(OBJS) $(PROG)
  444. END_OF_FILE
  445. if test 1009 -ne `wc -c <'Makefile.sun.3.0'`; then
  446.     echo shar: \"'Makefile.sun.3.0'\" unpacked with wrong size!
  447. fi
  448. # end of 'Makefile.sun.3.0'
  449. fi
  450. if test -f 'Makefile.sun.3.2' -a "${1}" != "-c" ; then 
  451.   echo shar: Will not clobber existing file \"'Makefile.sun.3.2'\"
  452. else
  453. echo shar: Extracting \"'Makefile.sun.3.2'\" \(1019 characters\)
  454. sed "s/^X//" >'Makefile.sun.3.2' <<'END_OF_FILE'
  455. X# Makefile for SPS (Sun-2 and Sun-3, Sun UNIX 4.2 Release 3.x Version)
  456. X
  457. PROG    =       sps
  458. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  459. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  460. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  461. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  462. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  463. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  464. INCS    =       sps.h
  465. CC      =       cc
  466. CFLAGS  =       -DSUN -DBSD42 -DNFS -DVPRINTF -I/sys
  467. LIBS    =       -ltermlib
  468. DIRINSTALL    = /bin
  469. X
  470. all:            $(PROG)
  471. X.c.o:
  472. X        $(CC) $(CFLAGS) -c -O -R $<
  473. X    
  474. globals1.o waitingfor.o:
  475. X        $(CC) $(CFLAGS) -c -O $<
  476. X
  477. X$(OBJS):        $(INCS)
  478. X
  479. X$(PROG):        $(OBJS)
  480. X        $(CC) -o $@ $(OBJS) $(LIBS)
  481. X
  482. install:        $(PROG)
  483. X        strip $(PROG)
  484. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  485. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  486. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  487. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  488. X
  489. lint:
  490. X        lint -x -b $(CFLAGS) *.c $(LIBS)
  491. clean:
  492. X        rm -f $(OBJS) $(PROG)
  493. END_OF_FILE
  494. if test 1019 -ne `wc -c <'Makefile.sun.3.2'`; then
  495.     echo shar: \"'Makefile.sun.3.2'\" unpacked with wrong size!
  496. fi
  497. # end of 'Makefile.sun.3.2'
  498. fi
  499. if test -f 'Makefile.sun.4.0' -a "${1}" != "-c" ; then 
  500.   echo shar: Will not clobber existing file \"'Makefile.sun.4.0'\"
  501. else
  502. echo shar: Extracting \"'Makefile.sun.4.0'\" \(1134 characters\)
  503. sed "s/^X//" >'Makefile.sun.4.0' <<'END_OF_FILE'
  504. X# Makefile for SPS (Sun-2, Sun-3 and Sun-4, SunOS 4.0 Version)
  505. X
  506. PROG    =       sps
  507. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  508. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  509. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  510. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  511. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  512. X        selectproc.o selecttty.o stream.o termwidth.o ttystatus.o \
  513. X        vmstat.o waitingfor.o
  514. INCS    =       sps.h
  515. CC      =       cc
  516. CFLAGS  =       -DSUN -DBSD42 -DNFS -DVPRINTF -DKVM -DSUNOS40 -Isys
  517. LIBS    =       -ltermlib -lkvm
  518. DIRINSTALL    = /usr/kvm
  519. X
  520. all:            $(PROG)
  521. X.c.o:
  522. X        $(CC) $(CFLAGS) -c -O -R $<
  523. X    
  524. globals1.o stream.o waitingfor.o:
  525. X        $(CC) $(CFLAGS) -c -O $<
  526. X
  527. X$(OBJS):        sys $(INCS)
  528. X
  529. sys:
  530. X        -mkdir sys
  531. X        -ln -s /sys/* sys
  532. X        -ln -s /sys/sys sys/h
  533. X
  534. X$(PROG):        $(OBJS)
  535. X        $(CC) -o $@ $(OBJS) $(LIBS)
  536. X
  537. install:        $(PROG)
  538. X        strip $(PROG)
  539. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  540. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  541. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  542. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  543. X
  544. lint:
  545. X        lint -x -b $(CFLAGS) *.c $(LIBS)
  546. clean:
  547. X        rm -f $(OBJS) $(PROG)
  548. END_OF_FILE
  549. if test 1134 -ne `wc -c <'Makefile.sun.4.0'`; then
  550.     echo shar: \"'Makefile.sun.4.0'\" unpacked with wrong size!
  551. fi
  552. # end of 'Makefile.sun.4.0'
  553. fi
  554. if test -f 'Makefile.sun.4.0+386i' -a "${1}" != "-c" ; then 
  555.   echo shar: Will not clobber existing file \"'Makefile.sun.4.0+386i'\"
  556. else
  557. echo shar: Extracting \"'Makefile.sun.4.0+386i'\" \(1144 characters\)
  558. sed "s/^X//" >'Makefile.sun.4.0+386i' <<'END_OF_FILE'
  559. X# Makefile for SPS (Sun-2, Sun-3 and Sun-4, SunOS 4.0 Version)
  560. X
  561. PROG    =       sps
  562. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  563. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  564. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  565. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  566. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  567. X        selectproc.o selecttty.o stream.o termwidth.o ttystatus.o \
  568. X        vmstat.o waitingfor.o
  569. INCS    =       sps.h
  570. CC      =       cc
  571. CFLAGS  =       -DSUN -DBSD42 -DNFS -DVPRINTF -DKVM -DSUNOS40 -DSUN386I -Isys
  572. LIBS    =       -ltermlib -lkvm
  573. DIRINSTALL    = /usr/kvm
  574. X
  575. all:            $(PROG)
  576. X.c.o:
  577. X        $(CC) $(CFLAGS) -c -O -R $<
  578. X    
  579. globals1.o stream.o waitingfor.o:
  580. X        $(CC) $(CFLAGS) -c -O $<
  581. X
  582. X$(OBJS):        sys $(INCS)
  583. X
  584. sys:
  585. X        -mkdir sys
  586. X        -ln -s /sys/* sys
  587. X        -ln -s /sys/sys sys/h
  588. X
  589. X$(PROG):        $(OBJS)
  590. X        $(CC) -o $@ $(OBJS) $(LIBS)
  591. X
  592. install:        $(PROG)
  593. X        strip $(PROG)
  594. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  595. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  596. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  597. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  598. X
  599. lint:
  600. X        lint -x -b $(CFLAGS) *.c $(LIBS)
  601. clean:
  602. X        rm -f $(OBJS) $(PROG)
  603. END_OF_FILE
  604. if test 1144 -ne `wc -c <'Makefile.sun.4.0+386i'`; then
  605.     echo shar: \"'Makefile.sun.4.0+386i'\" unpacked with wrong size!
  606. fi
  607. # end of 'Makefile.sun.4.0+386i'
  608. fi
  609. if test -f 'Makefile.sun.4.1' -a "${1}" != "-c" ; then 
  610.   echo shar: Will not clobber existing file \"'Makefile.sun.4.1'\"
  611. else
  612. echo shar: Extracting \"'Makefile.sun.4.1'\" \(1210 characters\)
  613. sed "s/^X//" >'Makefile.sun.4.1' <<'END_OF_FILE'
  614. X# Makefile for SPS (Sun-2, Sun-3 and Sun-4, SunOS 4.1 Version)
  615. X
  616. PROG    =       sps
  617. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  618. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  619. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  620. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  621. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  622. X        selectproc.o selecttty.o stream.o termwidth.o ttystatus.o \
  623. X        vmstat.o waitingfor.o
  624. INCS    =       sps.h
  625. CC      =       cc
  626. X# You'll need both "-DSUNOS40" and "-DSUNOS41" for SunOS 4.1
  627. CFLAGS  =    -DSUN -DBSD42 -DNFS -DVPRINTF -DKVM -DSUNOS40 -DSUNOS41 -Isys
  628. LIBS    =       -ltermlib -lkvm
  629. DIRINSTALL    = /usr/kvm
  630. X
  631. all:            $(PROG)
  632. X.c.o:
  633. X        $(CC) $(CFLAGS) -c -O -R $<
  634. X
  635. globals1.o stream.o waitingfor.o filecount.o:
  636. X        $(CC) $(CFLAGS) -c -O $<
  637. X
  638. X$(OBJS):        sys $(INCS)
  639. X
  640. sys:
  641. X        -mkdir sys
  642. X        -ln -s /sys/* sys
  643. X        -ln -s /sys/sys sys/h
  644. X
  645. X$(PROG):        $(OBJS)
  646. X        $(CC) -o $@ $(OBJS) $(LIBS)
  647. X
  648. install:        $(PROG)
  649. X        strip $(PROG)
  650. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  651. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  652. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  653. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  654. X
  655. lint:
  656. X        lint -x -b $(CFLAGS) *.c $(LIBS)
  657. clean:
  658. X        rm -f $(OBJS) $(PROG)
  659. END_OF_FILE
  660. if test 1210 -ne `wc -c <'Makefile.sun.4.1'`; then
  661.     echo shar: \"'Makefile.sun.4.1'\" unpacked with wrong size!
  662. fi
  663. # end of 'Makefile.sun.4.1'
  664. fi
  665. if test -f 'Makefile.sun4.3.2' -a "${1}" != "-c" ; then 
  666.   echo shar: Will not clobber existing file \"'Makefile.sun4.3.2'\"
  667. else
  668. echo shar: Extracting \"'Makefile.sun4.3.2'\" \(1066 characters\)
  669. sed "s/^X//" >'Makefile.sun4.3.2' <<'END_OF_FILE'
  670. X# Makefile for SPS (Sun-4, SunOS Sys 4-3.2 Version)
  671. X
  672. PROG    =       sps
  673. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  674. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  675. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  676. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  677. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  678. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  679. INCS    =       sps.h
  680. CC      =       cc
  681. CFLAGS  =       -DSUN -DBSD42 -DNFS -DVPRINTF -Isys
  682. LIBS    =       -ltermlib
  683. DIRINSTALL    = /bin
  684. X
  685. all:            $(PROG)
  686. X.c.o:
  687. X        $(CC) $(CFLAGS) -c -O -R $<
  688. X    
  689. globals1.o waitingfor.o:
  690. X        $(CC) $(CFLAGS) -c -O $<
  691. X
  692. X$(OBJS):        sys $(INCS)
  693. X
  694. sys:
  695. X        -mkdir sys
  696. X        -ln -s /sys/* sys
  697. X        -ln -s /sys/sys sys/h
  698. X
  699. X$(PROG):        $(OBJS)
  700. X        $(CC) -o $@ $(OBJS) $(LIBS)
  701. X
  702. install:        $(PROG)
  703. X        strip $(PROG)
  704. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  705. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  706. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  707. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  708. X
  709. lint:
  710. X        lint -x -b $(CFLAGS) *.c $(LIBS)
  711. clean:
  712. X        rm -f $(OBJS) $(PROG)
  713. END_OF_FILE
  714. if test 1066 -ne `wc -c <'Makefile.sun4.3.2'`; then
  715.     echo shar: \"'Makefile.sun4.3.2'\" unpacked with wrong size!
  716. fi
  717. # end of 'Makefile.sun4.3.2'
  718. fi
  719. if test -f 'Makefile.ultrix.2.0' -a "${1}" != "-c" ; then 
  720.   echo shar: Will not clobber existing file \"'Makefile.ultrix.2.0'\"
  721. else
  722. echo shar: Extracting \"'Makefile.ultrix.2.0'\" \(984 characters\)
  723. sed "s/^X//" >'Makefile.ultrix.2.0' <<'END_OF_FILE'
  724. X# Makefile for SPS (Ultrix 2.0 UNIX Version)
  725. X
  726. PROG    =       sps
  727. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  728. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  729. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  730. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  731. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  732. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  733. INCS    =       sps.h
  734. CC      =       cc
  735. CFLAGS  =       -DBSD42 -DULTRIX20 -DVPRINTF -I/sys
  736. LIBS    =       -ltermlib
  737. DIRINSTALL =    /bin
  738. X
  739. all:            $(PROG)
  740. X.c.o:
  741. X        $(CC) $(CFLAGS) -c -O -R $<
  742. X    
  743. globals1.o waitingfor.o:
  744. X        $(CC) $(CFLAGS) -c -O $<
  745. X
  746. X$(OBJS):        $(INCS)
  747. X
  748. X$(PROG):        $(OBJS)
  749. X        $(CC) -o $@ $(OBJS) $(LIBS)
  750. X
  751. install:        $(PROG)
  752. X        strip $(PROG)
  753. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  754. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  755. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  756. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  757. X
  758. lint:
  759. X        lint -x -b $(CFLAGS) *.c
  760. clean:
  761. X        rm -f $(OBJS) $(PROG)
  762. END_OF_FILE
  763. if test 984 -ne `wc -c <'Makefile.ultrix.2.0'`; then
  764.     echo shar: \"'Makefile.ultrix.2.0'\" unpacked with wrong size!
  765. fi
  766. # end of 'Makefile.ultrix.2.0'
  767. fi
  768. if test -f 'Makefile.ultrix.3.0' -a "${1}" != "-c" ; then 
  769.   echo shar: Will not clobber existing file \"'Makefile.ultrix.3.0'\"
  770. else
  771. echo shar: Extracting \"'Makefile.ultrix.3.0'\" \(995 characters\)
  772. sed "s/^X//" >'Makefile.ultrix.3.0' <<'END_OF_FILE'
  773. X# Makefile for SPS (Ultrix 2.0 UNIX Version)
  774. X
  775. PROG    =       sps
  776. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  777. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  778. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  779. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  780. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  781. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  782. INCS    =       sps.h
  783. CC      =       cc
  784. CFLAGS  =       -DBSD42 -DULTRIX20 -DULTRIX30 -DVPRINTF -I/sys
  785. LIBS    =       -ltermlib
  786. DIRINSTALL =    /bin
  787. X
  788. all:            $(PROG)
  789. X.c.o:
  790. X        $(CC) $(CFLAGS) -c -O -R $<
  791. X    
  792. globals1.o waitingfor.o:
  793. X        $(CC) $(CFLAGS) -c -O $<
  794. X
  795. X$(OBJS):        $(INCS)
  796. X
  797. X$(PROG):        $(OBJS)
  798. X        $(CC) -o $@ $(OBJS) $(LIBS)
  799. X
  800. install:        $(PROG)
  801. X        strip $(PROG)
  802. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  803. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  804. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  805. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  806. X
  807. lint:
  808. X        lint -x -b $(CFLAGS) *.c
  809. clean:
  810. X        rm -f $(OBJS) $(PROG)
  811. END_OF_FILE
  812. if test 995 -ne `wc -c <'Makefile.ultrix.3.0'`; then
  813.     echo shar: \"'Makefile.ultrix.3.0'\" unpacked with wrong size!
  814. fi
  815. # end of 'Makefile.ultrix.3.0'
  816. fi
  817. if test -f 'Makefile.ultrix.4.0' -a "${1}" != "-c" ; then 
  818.   echo shar: Will not clobber existing file \"'Makefile.ultrix.4.0'\"
  819. else
  820. echo shar: Extracting \"'Makefile.ultrix.4.0'\" \(1006 characters\)
  821. sed "s/^X//" >'Makefile.ultrix.4.0' <<'END_OF_FILE'
  822. X# Makefile for SPS (Ultrix 2.0 UNIX Version)
  823. X
  824. PROG    =       sps
  825. OBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  826. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  827. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  828. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  829. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  830. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  831. INCS    =       sps.h
  832. CC      =       cc
  833. CFLAGS  =       -DBSD42 -DULTRIX20 -DULTRIX30 -DULTRIX40 -DVPRINTF -I/sys
  834. LIBS    =       -ltermlib
  835. DIRINSTALL =    /bin
  836. X
  837. all:            $(PROG)
  838. X.c.o:
  839. X        $(CC) $(CFLAGS) -c -O -R $<
  840. X    
  841. globals1.o waitingfor.o:
  842. X        $(CC) $(CFLAGS) -c -O $<
  843. X
  844. X$(OBJS):        $(INCS)
  845. X
  846. X$(PROG):        $(OBJS)
  847. X        $(CC) -o $@ $(OBJS) $(LIBS)
  848. X
  849. install:        $(PROG)
  850. X        strip $(PROG)
  851. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  852. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  853. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  854. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  855. X
  856. lint:
  857. X        lint -x -b $(CFLAGS) *.c
  858. clean:
  859. X        rm -f $(OBJS) $(PROG)
  860. END_OF_FILE
  861. if test 1006 -ne `wc -c <'Makefile.ultrix.4.0'`; then
  862.     echo shar: \"'Makefile.ultrix.4.0'\" unpacked with wrong size!
  863. fi
  864. # end of 'Makefile.ultrix.4.0'
  865. fi
  866. if test -f 'README' -a "${1}" != "-c" ; then 
  867.   echo shar: Will not clobber existing file \"'README'\"
  868. else
  869. echo shar: Extracting \"'README'\" \(4667 characters\)
  870. sed "s/^X//" >'README' <<'END_OF_FILE'
  871. X        SPS  -  Show Process Status
  872. X        ===========================
  873. X
  874. X
  875. Introduction:
  876. X    SPS is a intended to be used as a replacement for the standard
  877. X    ps(1) program. Its advantages over ps(1) are that it shows more
  878. X    useful information, that the displayed information is more
  879. X    comprehensible and that it is faster.
  880. X
  881. X
  882. X    SPS is currently implemented for the following operating systems and
  883. X    architectures.  The corresponding Makefiles are also shown here:
  884. X
  885. X    Makefile.4.1        Standard 4.1bsd for Vax
  886. X    Makefile.4.2        Standard 4.2bsd, Ultrix 1.x for Vax
  887. X    Makefile.4.3        Standard 4.3bsd (or 4.3-tahoe) for Vax
  888. X    Makefile.4.3+NFS    4.3bsd+NFS from Wisconsin (Mt. Xinu?, others?)
  889. X    Makefile.sun.2.0    Sun 4.2 UNIX Release 2.0 - 2.2 for Sun-2
  890. X    Makefile.sun.3.0    Sun 4.2 UNIX Release 3.0 for Sun-2, Sun-3
  891. X    Makefile.sun.3.2    Sun 4.2 UNIX Release 3.2 for Sun-2, Sun-3
  892. X    Makefile.sun.4.0    SunOS 4.0 for Sun-2, Sun-3, Sun-4
  893. X    Makefile.sun.4.0+386i    SunOS 4.0 for Sun 386i
  894. X    Makefile.sun.4.1    SunOS 4.1 for Sun-2, Sun-3, Sun-4
  895. X    Makefile.sun4.3.2    SunOS Sys 4-3.2 for Sun-4
  896. X    Makefile.ultrix.2.0    DEC Ultrix 2.0 - 2.2
  897. X    Makefile.ultrix.3.0    DEC Ultrix 3.0
  898. X    Makefile.ultrix.4.0    DEC Ultrix 4.x
  899. X
  900. X    (I also have a somewhat ancient implementation for V7 on a PDP-11 as well
  901. X    as Unisoft Version 1.3 on a MC68000 if anyone is interested).
  902. X
  903. X
  904. What SPS does:
  905. X    SPS displays wait channels symbolically, rather than as hexadecimal
  906. X    addresses.  (If you wish to teach SPS about a new sort of device,
  907. X    you must add an entry in the symbol table (globals2.c) as well as
  908. X    increasing the size of that table (NWAITSTATE in sps.h)).
  909. X
  910. X    SPS sorts processes before listing them, the order reflecting the
  911. X    relationship of the processes.  A child process is listed
  912. X    underneath its corresponding parent and is indented to depict the
  913. X    exact relationship.  SPS also indicates setuid processes.
  914. X
  915. X    SPS displays such values as the resident and virtual sizes of
  916. X    system processes.  It accepts a whole range of options to control
  917. X    the output.  By default, SPS lists information about one's own
  918. X    processes.  Other options instruct it to be verbose (the "v"
  919. X    option), to list all the command arguments of a process (the "w"
  920. X    option) or to list the environment strings of that process (the "e"
  921. X    option).  Similarly, there are options to control which processes
  922. X    are to be displayed.  The "a" option tells it to describe all
  923. X    processes and the "b" option tells it to describe "busy" processes;
  924. X    the latter is useful if you wish to find out what is loading your
  925. X    system.  There are also options to select the output according to
  926. X    user, controlling tty or process number.
  927. X
  928. X    SPS keeps its information in an information file; by default, this
  929. X    is /tmp/.spsinfo. This means that it can avoid having to do an
  930. X    expensive nlist() operation each time it is run.  It must be
  931. X    reinitialised (with the "i" option) if new users are added to
  932. X    /etc/passwd or if a new version of /vmunix is installed.
  933. X
  934. X
  935. How to build SPS:
  936. X    1. In order to compile and install SPS, first unbundle the three shell
  937. X       archive files.
  938. X    2. Check that the define statements in sps.h are large enough for
  939. X       your system.  In particular, you may need to increase MAXTTYS
  940. X       to reflect the number of tty devices in /dev.  The parameter
  941. X       MAXUSERS defines the maximum number of users defined in the
  942. X       password file (or through the Yellow Pages).  Because the
  943. X       user-ids are held in an internal hash table, this should
  944. X       probably be at least double the number of actual users.
  945. X    3. Choose an appropriate Makefile from the table above and compile
  946. X       the source files.  For example:
  947. X       % make -f Makefile.sun.3.2
  948. X    4. Try running SPS.  First, a suitable information file must be
  949. X       initialised.  It should then be able to display information
  950. X       concerning running processes on your system:
  951. X         # Initialise SPS.  Ignore any error messages at this stage.
  952. X       % sps i
  953. X         # Instruct SPS to list all active processes in verbose format.
  954. X       % sps va
  955. X    5. If this all works, install SPS with the appropriate Makefile
  956. X       and reinitialise it:
  957. X       % make -f Makefile.sun.3.2 install
  958. X       % sps -i
  959. X
  960. X
  961. Bug reports:
  962. X    Send all bug reports, fixes, comments and suggestions to Robert Ward at -
  963. X
  964. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  965. X    J. Robert Ward,
  966. X    Olsen & Associates AG, Seefeldstrasse 233, CH-8008 Zuerich, Switzerland
  967. X
  968. Tel.:   +41 1 552224           Fax: +41 1 552282
  969. XEmail:  robert@olsen.ch        Uucp:  uunet!olsen!robert
  970. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  971. END_OF_FILE
  972. if test 4667 -ne `wc -c <'README'`; then
  973.     echo shar: \"'README'\" unpacked with wrong size!
  974. fi
  975. # end of 'README'
  976. fi
  977. if test -f 'RELEASENOTES' -a "${1}" != "-c" ; then 
  978.   echo shar: Will not clobber existing file \"'RELEASENOTES'\"
  979. else
  980. echo shar: Extracting \"'RELEASENOTES'\" \(1230 characters\)
  981. sed "s/^X//" >'RELEASENOTES' <<'END_OF_FILE'
  982. X        YET  ANOTHER  RELEASE  OF  SPS
  983. X        ==============================
  984. X
  985. X
  986. This release of sps corrects some bugs in previous versions.  It also
  987. includes support for Ultrix 4.x on DecStation 3100s and related animals as
  988. well as on Vaxen.
  989. X
  990. The Ultrix 4.x support does not function as well as on other operating
  991. systems.  Command line arguments are not determined.  However the name of
  992. the running program and other upage information is found correctly.  (If
  993. anyone knows how to make this work properaly, please let me know).
  994. X
  995. Many thanks to all those who provided bug reports and other input and to
  996. those too who helped in beta-testing.  The latter include Jamie Watson
  997. X<jw@pan.adasoft.ch> and Robert Owen <owen@hasler.ascom.ch>.
  998. X
  999. No thanks at all to DEC who made the Ultrix 4.x internals so painfully and
  1000. obscurely different from any other version of Unix known to mankind.
  1001. X
  1002. X
  1003. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1004. X    J. Robert Ward,
  1005. X    Olsen & Associates AG, Seefeldstrasse 233, CH-8008 Zuerich, Switzerland
  1006. X
  1007. Tel.:   +41 1 552224           Fax: +41 1 552282
  1008. XEmail:  robert@olsen.ch        Uucp:  uunet!olsen!robert
  1009. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1010. END_OF_FILE
  1011. if test 1230 -ne `wc -c <'RELEASENOTES'`; then
  1012.     echo shar: \"'RELEASENOTES'\" unpacked with wrong size!
  1013. fi
  1014. # end of 'RELEASENOTES'
  1015. fi
  1016. if test -f 'filecount.c' -a "${1}" != "-c" ; then 
  1017.   echo shar: Will not clobber existing file \"'filecount.c'\"
  1018. else
  1019. echo shar: Extracting \"'filecount.c'\" \(1586 characters\)
  1020. sed "s/^X//" >'filecount.c' <<'END_OF_FILE'
  1021. X# ifndef lint
  1022. static char SccsId[] =  "@(#)filecount.c    1.3\t8/22/91" ;
  1023. X# endif
  1024. X
  1025. X# include       "sps.h"
  1026. X
  1027. X/* FILECOUNT - Counts the # open files for the current process */
  1028. filecount ( p )
  1029. X
  1030. struct process         *p ;
  1031. X
  1032. X{
  1033. X    register int            i ;
  1034. X    register struct file    **f ;
  1035. X    register int            count ;
  1036. X    extern union userstate  User ;
  1037. X# ifdef SUNOS41
  1038. X    /*
  1039. X     * The open file list is in User.u_us.u_ofile_arr
  1040. X     * if User.u_us.u_ofile points to it; otherwise we'll have
  1041. X     * do it the hard way by reading the list from kmem.
  1042. X     *
  1043. X     * Read the comment to u_ofile in /usr/include/sys/user.h.
  1044. X     */
  1045. X
  1046. X    int            len ;
  1047. X    static char        *files = 0 ;
  1048. X    static int         files_len = 0 ;
  1049. X    extern char        *getcore () ;
  1050. X# endif SUNOS41
  1051. X
  1052. X
  1053. X# ifdef SUNOS41
  1054. X
  1055. X#  ifndef offsetof
  1056. X#   define offsetof(type,member)    ((long) &(((type *) 0)->member))
  1057. X#  endif offsetof
  1058. X
  1059. X    if ( (long) User.u_us.u_ofile ==
  1060. X        (long) p->pr_p.p_uarea + offsetof(struct user, u_ofile_arr[0]) )
  1061. X        f = &User.u_us.u_ofile_arr[ 0 ] ;
  1062. X    else
  1063. X    {
  1064. X        len = User.u_us.u_lastfile * sizeof (struct file *) ;
  1065. X        if (len <= 0)
  1066. X            return 0;
  1067. X        if (files == 0 || len > files_len)
  1068. X        {
  1069. X            if (files != 0)
  1070. X                free (files) ;
  1071. X            files = (char *) getcore(len) ;
  1072. X            files_len = len ;
  1073. X        }
  1074. X        if ( getkmem( (long)User.u_us.u_ofile, (char *)files, len)
  1075. X        != len )
  1076. X            return 0 ;
  1077. X        f = (struct file **)files ;
  1078. X    }
  1079. X    count = 0 ;
  1080. X    for ( i = 0 ; i < User.u_us.u_lastfile ; i++ )
  1081. X        if ( *f++ )
  1082. X            count++ ;
  1083. X    return ( count ) ;
  1084. X# else SUNOS41
  1085. X    count = 0 ;
  1086. X    for ( i = 0, f = User.u_us.u_ofile ; i < NOFILE ; i++ )
  1087. X        if ( *f++ )
  1088. X            count++ ;
  1089. X    return ( count ) ;
  1090. X# endif SUNOS41
  1091. X}
  1092. END_OF_FILE
  1093. if test 1586 -ne `wc -c <'filecount.c'`; then
  1094.     echo shar: \"'filecount.c'\" unpacked with wrong size!
  1095. fi
  1096. # end of 'filecount.c'
  1097. fi
  1098. if test -f 'findtty.c' -a "${1}" != "-c" ; then 
  1099.   echo shar: Will not clobber existing file \"'findtty.c'\"
  1100. else
  1101. echo shar: Extracting \"'findtty.c'\" \(1324 characters\)
  1102. sed "s/^X//" >'findtty.c' <<'END_OF_FILE'
  1103. X# ifndef lint
  1104. static char SccsId[] =  "@(#)findtty.c    1.4\t8/6/90" ;
  1105. X# endif
  1106. X
  1107. X# include       "sps.h"
  1108. X# include       <h/ioctl.h>
  1109. X# ifdef SUNOS40
  1110. X# include       <h/stream.h>
  1111. X# else
  1112. X# include       <h/tty.h>
  1113. X# endif
  1114. X# ifdef SUNOS41
  1115. X# include    <h/session.h>
  1116. X# endif
  1117. X
  1118. X/* FINDTTY - Attempts to determine to which tty a process is connected */
  1119. struct ttyline  *findtty ( p )
  1120. X
  1121. register struct process         *p ;
  1122. X
  1123. X{
  1124. X    register struct ttyline *lp ;
  1125. X    extern struct info      Info ;
  1126. X    extern struct ttyline   Notty ;
  1127. X# ifdef SUNOS41
  1128. X    struct sess        *s ;
  1129. X    extern struct sess    *find_session () ;
  1130. X# else
  1131. X    extern union userstate  User ;
  1132. X# endif SUNOS41
  1133. X
  1134. X
  1135. X# ifdef SUNOS41
  1136. X    if ( !p->pr_p.p_pgrp || !p->pr_p.p_sessp )
  1137. X        return ( &Notty ) ;
  1138. X    s = find_session( p->pr_p.p_sessp ) ;
  1139. X    if ( s == 0 || s->s_ttyp == 0 )
  1140. X        return &Notty;
  1141. X    for ( lp = Info.i_ttyline ; lp->l_name[0] ; lp++ )
  1142. X        if ( lp->l_dev == s->s_ttyd )
  1143. X            return ( lp ) ;
  1144. X    /* Kludge from outer space    ++sja */
  1145. X    if ( s->s_ttyd == 256 )
  1146. X        return &Info.i_ttyline[0] ;
  1147. X    return ( &Notty ) ;
  1148. X# else
  1149. X#  ifdef ULTRIX30
  1150. X    if ( !p->pr_p.p_pgrp || !p->pr_p.p_ttyp )
  1151. X#  else
  1152. X    if ( !p->pr_p.p_pgrp || !User.u_us.u_ttyp )
  1153. X#  endif
  1154. X        return ( &Notty ) ;
  1155. X    for ( lp = Info.i_ttyline ; lp->l_name[0] ; lp++ )
  1156. X        if ( lp->l_dev == User.u_us.u_ttyd )
  1157. X            return ( lp ) ;
  1158. X    return ( &Notty ) ;
  1159. X#endif SUNOS41
  1160. X}
  1161. END_OF_FILE
  1162. if test 1324 -ne `wc -c <'findtty.c'`; then
  1163.     echo shar: \"'findtty.c'\" unpacked with wrong size!
  1164. fi
  1165. # end of 'findtty.c'
  1166. fi
  1167. if test -f 'flags.h' -a "${1}" != "-c" ; then 
  1168.   echo shar: Will not clobber existing file \"'flags.h'\"
  1169. else
  1170. echo shar: Extracting \"'flags.h'\" \(2638 characters\)
  1171. sed "s/^X//" >'flags.h' <<'END_OF_FILE'
  1172. X# ifndef lint
  1173. static char FlagsHId[] =  "@(#)flags.h    1.1\t10/1/88" ;
  1174. X# endif
  1175. X
  1176. X/* Structure holding information specified in the option list ... */
  1177. union flaglist
  1178. X{
  1179. X    char                    *f_chp ;        /* Option specified as string */
  1180. X    int                     f_uid ;         /* Numerical user id */
  1181. X    int                     f_pid ;         /* Numerical process id */
  1182. X    struct ttyline          *f_ttyline ;    /* Specified tty */
  1183. X} ;
  1184. X
  1185. X/* Structure holding global information specifed by arg list options ... */
  1186. struct flags
  1187. X{
  1188. X    int                     flg_c:1 ;       /* print command from upage */
  1189. X    int                     flg_d:1 ;       /* disc orientated output */
  1190. X    int                     flg_e:1 ;       /* print environment string */
  1191. X    int                     flg_f:1 ;       /* print process father # */
  1192. X    int                     flg_g:1 ;       /* print process group # */
  1193. X    int                     flg_i:1 ;       /* initialise sps */
  1194. X    char                    *flg_j ;        /* Use this as the info file */
  1195. X    char                    *flg_k ;        /* Use this as the {k}mem file*/
  1196. X    int                     flg_o:1 ;       /* avoid the swap device */
  1197. X    int                     flg_q:1 ;       /* show user time only */
  1198. X    int                     flg_r:1 ;       /* repeat output */
  1199. X    unsigned                flg_rdelay ;    /* ... with this much delay */
  1200. X    char                    *flg_s ;        /* Use this as the symbol file*/
  1201. X    int                     flg_v:1 ;       /* print verbose listing */
  1202. X    int                     flg_w:1 ;       /* print wide output */
  1203. X    int                     flg_y:1 ;       /* print tty information */
  1204. X    int                     flg_A:1 ;       /* print all processes */
  1205. X    int                     flg_B:1 ;       /* print busy processes */
  1206. X    int                     flg_F:1 ;       /* print foreground processes */
  1207. X    int                     flg_N:1 ;       /* print no processes */
  1208. X    int                     flg_P:1 ;       /* print specified process #'s*/
  1209. X    int                     flg_S:1 ;       /* print stopped processes */
  1210. X    int                     flg_T:1 ;       /* print procs for given ttys */
  1211. X    int                     flg_U:1 ;       /* print procs for given users*/
  1212. X    int                     flg_W:1 ;       /* print waiting processes */
  1213. X    int                     flg_Z:1 ;       /* print zombie processes */
  1214. X    int                     flg_AZ:1 ;      /* One of A to Z was specified*/
  1215. X    union flaglist          *flg_Plist ;    /* List of specified processes*/
  1216. X    union flaglist          *flg_Tlist ;    /* List of specified ttys */
  1217. X    union flaglist          *flg_Ulist ;    /* List of specified users */
  1218. X} ;
  1219. END_OF_FILE
  1220. if test 2638 -ne `wc -c <'flags.h'`; then
  1221.     echo shar: \"'flags.h'\" unpacked with wrong size!
  1222. fi
  1223. # end of 'flags.h'
  1224. fi
  1225. if test -f 'flagsetup.c' -a "${1}" != "-c" ; then 
  1226.   echo shar: Will not clobber existing file \"'flagsetup.c'\"
  1227. else
  1228. echo shar: Extracting \"'flagsetup.c'\" \(2151 characters\)
  1229. sed "s/^X//" >'flagsetup.c' <<'END_OF_FILE'
  1230. X# ifndef lint
  1231. static char SccsId[] =  "@(#)flagsetup.c    1.2\t6/27/91" ;
  1232. X# endif
  1233. X
  1234. X# include       "sps.h"
  1235. X# include       "flags.h"
  1236. X# include       <h/ioctl.h>
  1237. X# ifdef SUNOS40
  1238. X# include       <h/stream.h>
  1239. X# endif
  1240. X# include       <h/tty.h>
  1241. X
  1242. X/*
  1243. X** FLAGSETUP - Replaces any users or processes specified by flagdecode()
  1244. X** with numerical equivalents. The lists are terminated by negative values.
  1245. X** or null pointers. Ttystatus() must have been previously called to
  1246. X** initialise the Info structure with chaos tty values.
  1247. X*/
  1248. flagsetup ()
  1249. X{
  1250. X    register union flaglist *fp ;
  1251. X    register char           *chp ;
  1252. X    register int            i ;
  1253. X    register struct ttyline *lp ;
  1254. X    int                     found ;
  1255. X    extern struct flags     Flg ;
  1256. X    extern struct info      Info ;
  1257. X
  1258. X    /* Look for specified users */
  1259. X    if ( Flg.flg_U )                
  1260. X    {
  1261. X        if ( !Flg.flg_Ulist->f_chp )
  1262. X            prexit( "sps - User name was expected after -u flag\n");
  1263. X        for ( fp = Flg.flg_Ulist ; chp = fp->f_chp ; fp++ )
  1264. X        {
  1265. X            found = 0 ;
  1266. X            for ( i = 0 ; i < MAXUSERS ; i++ )
  1267. X                if ( !strncmp( chp, Info.i_hnames[i].h_uname,
  1268. X                    UNAMELEN ) )
  1269. X                {
  1270. X                    fp->f_uid = Info.i_hnames[i].h_uid ;
  1271. X                    found = 1 ;
  1272. X                    break ;
  1273. X                }
  1274. X            if ( !found )
  1275. X                prexit( "sps - Unknown user: %s\n", chp ) ;
  1276. X        }
  1277. X        fp->f_uid = -1 ;
  1278. X    }
  1279. X    /* Look for specified process ids */
  1280. X    if ( Flg.flg_P )                
  1281. X    {
  1282. X        if ( !Flg.flg_Plist->f_chp )
  1283. X            prexit(
  1284. X                 "sps - Process id was expected after -p flag\n" ) ;
  1285. X        for ( fp = Flg.flg_Plist ; chp = fp->f_chp ; fp++ )
  1286. X        {
  1287. X            if ( chp[0] < '0' || chp[0] > '9' )
  1288. X                prexit( "sps - Bad process id: %s\n", chp ) ;
  1289. X            fp->f_pid = atoi( chp ) ;
  1290. X        }
  1291. X        fp->f_pid = -1 ;
  1292. X    }
  1293. X    /* Look for specified ttys */
  1294. X    if ( !Flg.flg_T )               
  1295. X        return ;
  1296. X    if ( !Flg.flg_Tlist->f_chp )
  1297. X        prexit( "sps - Tty name was expected after -t flag\n" ) ;
  1298. X    for ( fp = Flg.flg_Tlist ; chp = fp->f_chp ; fp++ )
  1299. X    {
  1300. X        found = 0 ;
  1301. X        for ( lp = Info.i_ttyline ; lp->l_name[0] ; lp++ )
  1302. X            if ( !strncmp( chp, lp->l_name, 2 ) )
  1303. X            {
  1304. X                fp->f_ttyline = lp ;
  1305. X                found = 1 ;
  1306. X                break ;
  1307. X            }
  1308. X        if ( !found )
  1309. X            prexit( "sps - Unknown tty name: %.2s\n", chp ) ;
  1310. X    }
  1311. X    fp->f_ttyline = (struct ttyline*)0 ;
  1312. X}
  1313. END_OF_FILE
  1314. if test 2151 -ne `wc -c <'flagsetup.c'`; then
  1315.     echo shar: \"'flagsetup.c'\" unpacked with wrong size!
  1316. fi
  1317. # end of 'flagsetup.c'
  1318. fi
  1319. if test -f 'globals1.c' -a "${1}" != "-c" ; then 
  1320.   echo shar: Will not clobber existing file \"'globals1.c'\"
  1321. else
  1322. echo shar: Extracting \"'globals1.c'\" \(945 characters\)
  1323. sed "s/^X//" >'globals1.c' <<'END_OF_FILE'
  1324. X# ifndef lint
  1325. static char SccsId[] =  "@(#)globals1.c    1.1\t10/1/88" ;
  1326. X# endif
  1327. X
  1328. X# include       "sps.h"
  1329. X# include       "flags.h"
  1330. X# ifdef KVM
  1331. X# include       <kvm.h>
  1332. X# endif
  1333. X
  1334. X/* Read/Write Variables global to the code of sps */
  1335. X
  1336. struct info                     Info ;          /* Information structure */
  1337. X
  1338. struct flags                    Flg ;           /* Flag options */
  1339. X
  1340. struct summary                  Summary ;       /* Summary of processes */
  1341. X
  1342. union  userstate                User ;          /* Upage of one process */
  1343. X
  1344. X# ifdef KVM
  1345. kvm_t                          *Flkvm ;         /* Kernel VM descriptor */
  1346. X# else
  1347. int                             Flmem, Flkmem, Flswap ; /* File descriptors */
  1348. X# endif
  1349. X
  1350. unsigned                        Termwidth ;     /* Width of output device */
  1351. X
  1352. short                           Lastpgrp ;      /* Last process pgrp printed */
  1353. X
  1354. short                           Lastuid ;       /* Last process uid printed */
  1355. END_OF_FILE
  1356. if test 945 -ne `wc -c <'globals1.c'`; then
  1357.     echo shar: \"'globals1.c'\" unpacked with wrong size!
  1358. fi
  1359. # end of 'globals1.c'
  1360. fi
  1361. if test -f 'hashuid.c' -a "${1}" != "-c" ; then 
  1362.   echo shar: Will not clobber existing file \"'hashuid.c'\"
  1363. else
  1364. echo shar: Extracting \"'hashuid.c'\" \(1515 characters\)
  1365. sed "s/^X//" >'hashuid.c' <<'END_OF_FILE'
  1366. X# ifndef lint
  1367. static char SccsId[] =  "@(#)hashuid.c    1.1\t10/1/88" ;
  1368. X# endif
  1369. X
  1370. X# include       "sps.h"
  1371. X
  1372. X/* The hashing functions themselves ... */
  1373. X# define        HASHFN1( a )            (((unsigned)(a)*91 + 17) % MAXUSERS)
  1374. X# define        HASHFN2( a )            (((unsigned)(a) + 47) % MAXUSERS)
  1375. X
  1376. X/*
  1377. X** HASHUID - Returns a pointer to a slot in the hash table that corresponds
  1378. X** to the hash table entry for `uid'. It returns a null pointer if there is
  1379. X** no such slot.
  1380. X*/
  1381. struct hashtab  *hashuid ( uid )
  1382. X
  1383. int                             uid ;
  1384. X
  1385. X{
  1386. X    register struct hashtab *hp ;
  1387. X    register int            i ;
  1388. X    register int            j ;
  1389. X    extern struct info      Info ;
  1390. X
  1391. X    j = HASHFN1( uid ) ;
  1392. X    for ( i = 0 ; i < MAXUSERS ; i++ )
  1393. X    {
  1394. X        hp = &Info.i_hnames[ j ] ;
  1395. X        if ( !hp->h_uname[0] )
  1396. X            return ( (struct hashtab*)0 ) ;
  1397. X        if ( hp->h_uid == uid )
  1398. X            return ( hp ) ;
  1399. X        j = HASHFN2( j ) ;
  1400. X    }
  1401. X    return ( (struct hashtab*)0 ) ;
  1402. X}
  1403. X
  1404. X/*
  1405. X** HASHNEXT - Returns a pointer to the next slot in the hash table that
  1406. X** may be use for storing information for `uid'. It returns a null pointer
  1407. X** if there are no more free slots available.
  1408. X*/
  1409. struct hashtab  *hashnext ( uid )
  1410. X
  1411. int                             uid ;
  1412. X
  1413. X{
  1414. X    register struct hashtab *hp ;
  1415. X    register int            i ;
  1416. X    register int            j ;
  1417. X    extern struct info      Info ;
  1418. X
  1419. X    j = HASHFN1( uid ) ;
  1420. X    for ( i = 0 ; i < MAXUSERS ; i++ )
  1421. X    {
  1422. X        hp = &Info.i_hnames[ j ] ;
  1423. X        if ( !hp->h_uname[0] )
  1424. X            return ( hp ) ;
  1425. X        j = HASHFN2( j ) ;
  1426. X    }
  1427. X    return ( (struct hashtab*)0 ) ;
  1428. X}
  1429. END_OF_FILE
  1430. if test 1515 -ne `wc -c <'hashuid.c'`; then
  1431.     echo shar: \"'hashuid.c'\" unpacked with wrong size!
  1432. fi
  1433. # end of 'hashuid.c'
  1434. fi
  1435. if test -f 'initialise.c' -a "${1}" != "-c" ; then 
  1436.   echo shar: Will not clobber existing file \"'initialise.c'\"
  1437. else
  1438. echo shar: Extracting \"'initialise.c'\" \(1986 characters\)
  1439. sed "s/^X//" >'initialise.c' <<'END_OF_FILE'
  1440. X# ifndef lint
  1441. static char SccsId[] =  "@(#)initialise.c    1.1\t10/1/88" ;
  1442. X# endif
  1443. X
  1444. X# include       "sps.h"
  1445. X# include       "flags.h"
  1446. X# include       <pwd.h>
  1447. X# include       <stdio.h>
  1448. X
  1449. X/*
  1450. X** INITIALISE - Called to reset the `Info' structure with new kernel
  1451. X** addresses and user and tty information.
  1452. X*/
  1453. initialise ()
  1454. X{
  1455. X    register FILE           *fd ;
  1456. X    char                    *fileinfo ;
  1457. X    extern struct flags     Flg ;
  1458. X    extern struct info      Info ;
  1459. X    FILE                    *fopen() ;
  1460. X
  1461. X    fileinfo = Flg.flg_j ? Flg.flg_j : FILE_INFO ;
  1462. X    /* Read kernel addresses */
  1463. X    initsymbols() ;                 
  1464. X    /* Read user names */
  1465. X    initusers() ;                   
  1466. X    (void)umask( ~0644 ) ;          
  1467. X    if ( !(fd = fopen( fileinfo, "w" )) )
  1468. X    {
  1469. X        fprintf( stderr, "sps - Can't create info file %s", fileinfo ) ;
  1470. X        sysperror() ;
  1471. X    }
  1472. X    /* Find tty addresses */
  1473. X    inittty() ;                     
  1474. X    if ( fwrite( (char*)&Info, sizeof( struct info ), 1, fd ) != 1 )
  1475. X    {
  1476. X        fprintf( stderr, "sps - Can't write info file %s", fileinfo ) ;
  1477. X        sysperror() ;
  1478. X        exit( 1 ) ;
  1479. X    }
  1480. X    (void)fclose( fd ) ;
  1481. X    printf( "sps is initialised\n" ) ;
  1482. X}
  1483. X
  1484. X/* INITUSERS - Read the passwd file and fill in the user name arrays */
  1485. initusers ()
  1486. X{
  1487. X    register struct passwd  *pw ;
  1488. X    register struct hashtab *hp ;
  1489. X    struct passwd           *getpwent() ;
  1490. X    char                    *strncpy() ;
  1491. X    struct hashtab          *hashuid(), *hashnext() ;
  1492. X
  1493. X    while ( pw = getpwent() )
  1494. X    {       /* For each user in the passwd file, first see if that uid
  1495. X           has been already allocated in the hash table. */
  1496. X        if ( hp = hashuid( pw->pw_uid ) )
  1497. X        {
  1498. X            fprintf( stderr,
  1499. X           "sps - Names %s and %s conflict in passwd file for uid %d\n",
  1500. X                hp->h_uname, pw->pw_name, pw->pw_uid ) ;
  1501. X            continue ;
  1502. X        }
  1503. X        /* Try to find a free slot in the hash table and fill it. */
  1504. X        if ( !(hp = hashnext( pw->pw_uid )) )
  1505. X            prexit( "sps - Too many users in passwd file\n" ) ;
  1506. X        hp->h_uid = pw->pw_uid ;
  1507. X        (void)strncpy( hp->h_uname, pw->pw_name, UNAMELEN ) ;
  1508. X    }
  1509. X    (void)endpwent() ;
  1510. X}
  1511. END_OF_FILE
  1512. if test 1986 -ne `wc -c <'initialise.c'`; then
  1513.     echo shar: \"'initialise.c'\" unpacked with wrong size!
  1514. fi
  1515. # end of 'initialise.c'
  1516. fi
  1517. if test -f 'mktree.c' -a "${1}" != "-c" ; then 
  1518.   echo shar: Will not clobber existing file \"'mktree.c'\"
  1519. else
  1520. echo shar: Extracting \"'mktree.c'\" \(1703 characters\)
  1521. sed "s/^X//" >'mktree.c' <<'END_OF_FILE'
  1522. X# ifndef lint
  1523. static char SccsId[] =  "@(#)mktree.c    1.1\t10/1/88" ;
  1524. X# endif
  1525. X
  1526. X# include       "sps.h"
  1527. X
  1528. X/*
  1529. X** MKTREE - Sort the needed processes by subtree and at the top by user.
  1530. X** This procedure takes a list of processes (as returned by needed())
  1531. X** and returnes a pointer to a sorted list.
  1532. X*/
  1533. struct process  *mktree ( process, plist )
  1534. X
  1535. struct process                  *process ;
  1536. struct process                  *plist ;
  1537. X
  1538. X{
  1539. X    register struct process *p ;
  1540. X    register struct process *pp ;
  1541. X    register struct process *lp ;
  1542. X    struct process          *op ;
  1543. X    struct process          proot ;
  1544. X
  1545. X    proot.pr_sibling = (struct process*)0 ;
  1546. X    for ( p = plist ; p ; p = p->pr_plink )
  1547. X    {
  1548. X        if ( p->pr_pptr > &process[1] )
  1549. X        {
  1550. X            for ( pp = plist ; pp ; pp = pp->pr_plink )
  1551. X            {
  1552. X                if ( pp != p->pr_pptr )
  1553. X                    continue ;
  1554. X                if ( lp = pp->pr_child )
  1555. X                {       /* Does process have children ? */
  1556. X                    op = (struct process*)0 ;
  1557. X                    while (lp &&
  1558. X                    lp->pr_p.p_pid < p->pr_p.p_pid )
  1559. X                    {
  1560. X                        op = lp ;
  1561. X                        lp=lp->pr_sibling ;
  1562. X                    }
  1563. X                    if ( op )
  1564. X                    {
  1565. X                        p->pr_sibling = lp ;
  1566. X                        op->pr_sibling = p ;
  1567. X                        break ;
  1568. X                    }
  1569. X                }       
  1570. X                p->pr_sibling = lp ;
  1571. X                pp->pr_child = p ;
  1572. X                break ;
  1573. X            }
  1574. X            if ( pp )
  1575. X                continue ;
  1576. X        }
  1577. X        /* We have a top level process, sort into top level list.
  1578. X           The top level is sorted firstly by user-id and then
  1579. X           by process-id. */
  1580. X        lp = &proot ;
  1581. X        pp = lp->pr_sibling ;
  1582. X        while ( pp )
  1583. X        {
  1584. X            if ( p->pr_p.p_uid < pp->pr_p.p_uid )
  1585. X                break ;
  1586. X            if ( p->pr_p.p_uid == pp->pr_p.p_uid
  1587. X            && p->pr_p.p_pid < pp->pr_p.p_pid )
  1588. X                break ;
  1589. X            lp = pp, pp = pp->pr_sibling ;
  1590. X        }
  1591. X        p->pr_sibling = lp->pr_sibling ;
  1592. X        lp->pr_sibling = p ;
  1593. X    }
  1594. X    return ( proot.pr_sibling ) ;
  1595. X}
  1596. END_OF_FILE
  1597. if test 1703 -ne `wc -c <'mktree.c'`; then
  1598.     echo shar: \"'mktree.c'\" unpacked with wrong size!
  1599. fi
  1600. # end of 'mktree.c'
  1601. fi
  1602. if test -f 'percentmem.c' -a "${1}" != "-c" ; then 
  1603.   echo shar: Will not clobber existing file \"'percentmem.c'\"
  1604. else
  1605. echo shar: Extracting \"'percentmem.c'\" \(1186 characters\)
  1606. sed "s/^X//" >'percentmem.c' <<'END_OF_FILE'
  1607. X# ifndef lint
  1608. static char SccsId[] =  "@(#)percentmem.c    1.2\t6/26/91" ;
  1609. X# endif
  1610. X
  1611. X# include       "sps.h"
  1612. X# ifndef SUNOS40
  1613. X# include       <h/text.h>
  1614. X# endif
  1615. X# ifdef BSD42
  1616. X# include    <machine/pte.h>
  1617. X# else
  1618. X# include       <h/pte.h>
  1619. X# include       <h/vmparam.h>
  1620. X# endif
  1621. X# include       <h/vmmac.h>
  1622. X
  1623. X/* PERCENTMEM - Returns the percentage of real memory used by this process */
  1624. double  percentmem ( p )
  1625. X
  1626. register struct process         *p ;
  1627. X
  1628. X{
  1629. X# ifndef SUNOS40
  1630. X    register struct text    *tp ;
  1631. X# endif
  1632. X    int                     szptudot ;
  1633. X    double                  fracmem ;
  1634. X    extern struct info      Info ;
  1635. X
  1636. X# ifdef SUNOS40
  1637. X    if ( !(p->pr_p.p_flag & SLOAD) )
  1638. X        return ( 0.0 ) ;
  1639. X    szptudot = UPAGES ;
  1640. X    fracmem = ( (double)p->pr_p.p_rssize + szptudot ) ;
  1641. X# else
  1642. X    tp = p->pr_p.p_textp ;
  1643. X# ifdef ULTRIX40
  1644. X    if ( !(p->pr_p.p_sched & SLOAD) || !tp )
  1645. X# else
  1646. X    if ( !(p->pr_p.p_flag & SLOAD) || !tp )
  1647. X# endif
  1648. X        return ( 0.0 ) ;
  1649. X    szptudot = UPAGES + clrnd( ctopt( p->pr_p.p_dsize + p->pr_p.p_ssize ) );
  1650. X    fracmem = ( (double)p->pr_p.p_rssize + szptudot ) / CLSIZE ;
  1651. X    if ( tp->x_ccount )
  1652. X        fracmem += ((double)tp->x_rssize)/CLSIZE/tp->x_ccount ;
  1653. X# endif
  1654. X    return ( 100.0 * fracmem / (double)Info.i_ecmx ) ;
  1655. X}
  1656. END_OF_FILE
  1657. if test 1186 -ne `wc -c <'percentmem.c'`; then
  1658.     echo shar: \"'percentmem.c'\" unpacked with wrong size!
  1659. fi
  1660. # end of 'percentmem.c'
  1661. fi
  1662. if test -f 'prcmd.c' -a "${1}" != "-c" ; then 
  1663.   echo shar: Will not clobber existing file \"'prcmd.c'\"
  1664. else
  1665. echo shar: Extracting \"'prcmd.c'\" \(785 characters\)
  1666. sed "s/^X//" >'prcmd.c' <<'END_OF_FILE'
  1667. X# ifndef lint
  1668. static char SccsId[] =  "@(#)prcmd.c    1.1\t10/1/88" ;
  1669. X# endif
  1670. X
  1671. X# include       "sps.h"
  1672. X# include       "flags.h"
  1673. X
  1674. X/* PRCMD - Prints the command arguments according to the switches */
  1675. prcmd ( p, lpad, width )
  1676. X
  1677. register struct process         *p ;
  1678. int                             lpad ;
  1679. int                             width ;
  1680. X
  1681. X{
  1682. X    extern struct flags     Flg ;
  1683. X    extern unsigned         Termwidth ;
  1684. X
  1685. X    printf( "%*d ", lpad, p->pr_p.p_pid ) ;
  1686. X    if ( Flg.flg_f )
  1687. X    {
  1688. X        printf( "%5d ", p->pr_p.p_ppid ) ;
  1689. X        width -= 6 ;
  1690. X    }
  1691. X    if ( Flg.flg_g )
  1692. X    {
  1693. X        printf( "%5d ", p->pr_p.p_pgrp ) ;
  1694. X        width -= 6 ;
  1695. X    }
  1696. X    width += Termwidth ;
  1697. X    if ( Flg.flg_w )
  1698. X        printf( "%s\n", p->pr_cmd ) ;
  1699. X    else if ( width > 0 )
  1700. X        printf( "%-.*s\n", width, p->pr_cmd ) ;
  1701. X    if ( p->pr_csaved )
  1702. X        free( p->pr_cmd ) ;
  1703. X}
  1704. END_OF_FILE
  1705. if test 785 -ne `wc -c <'prcmd.c'`; then
  1706.     echo shar: \"'prcmd.c'\" unpacked with wrong size!
  1707. fi
  1708. # end of 'prcmd.c'
  1709. fi
  1710. if test -f 'prcpu.c' -a "${1}" != "-c" ; then 
  1711.   echo shar: Will not clobber existing file \"'prcpu.c'\"
  1712. else
  1713. echo shar: Extracting \"'prcpu.c'\" \(1614 characters\)
  1714. sed "s/^X//" >'prcpu.c' <<'END_OF_FILE'
  1715. X# ifndef lint
  1716. static char SccsId[] =  "@(#)prcpu.c    1.1\t10/1/88" ;
  1717. X# endif
  1718. X
  1719. X# include       "sps.h"
  1720. X
  1721. X# ifdef BSD42
  1722. X
  1723. X/* PRCPU - Print cpu time */
  1724. prcpu ( time, utime )
  1725. X
  1726. register time_t                 time ;
  1727. time_t                          utime ;
  1728. X
  1729. X{
  1730. X    time += utime / 1000000 ;
  1731. X    utime %= 1000000 ;
  1732. X    if ( time < 0L )
  1733. X    {       /* Ignore negative times */
  1734. X        printf( "     " ) ;     
  1735. X        return ;
  1736. X    }
  1737. X    if ( time < 60L*10L )
  1738. X    {       /* Print as seconds if less than 1000 seconds */
  1739. X        printf( "%3d.%1d", (int)time, (int)utime/100000 ) ;
  1740. X        return ;
  1741. X    }
  1742. X    /* Print as minutes if less than 10 hours ; print as hours if less than
  1743. X       10 days, else print as days. */
  1744. X    if ( time < 60L*60L*10L )               
  1745. X        printf( "%3D M", time/60L ) ;
  1746. X    else if ( time < 24L*60L*60L*10L )
  1747. X        printf( "%3D H", time/60L/60L ) ;
  1748. X    else
  1749. X        printf( "%3D D", time/60L/60L/24L ) ;
  1750. X}
  1751. X
  1752. X# else
  1753. X
  1754. X/* PRCPU - Print cpu time */
  1755. prcpu ( time )
  1756. X
  1757. register time_t                 time ;
  1758. X
  1759. X{
  1760. X    extern struct info      Info ;
  1761. X
  1762. X    if ( time < 0L )
  1763. X    {       /* Ignore negative times */
  1764. X        printf( "     " ) ;     
  1765. X        return ;
  1766. X    }
  1767. X    if ( time < Info.i_hz*60L*10L )
  1768. X    {       /* Less than 10 minutes */
  1769. X        printf( "%3D.%1D", time/Info.i_hz,
  1770. X            (time % Info.i_hz / (Info.i_hz/10L)) ) ;
  1771. X        return ;
  1772. X    }
  1773. X    /* If less than 10 hours, print as minutes */
  1774. X    time /= Info.i_hz ;
  1775. X    /* Print as minutes if less than 10 hours ; print as hours if less than
  1776. X       10 days, else print as days. */
  1777. X    if ( time < 60L*60L*10L )               
  1778. X        printf( "%3D M", time/60L ) ;
  1779. X    else if ( time < 24L*60L*60L*10L )
  1780. X        printf( "%3D H", time/60L/60L ) ;
  1781. X    else
  1782. X        printf( "%3D D", time/60L/60L/24L ) ;
  1783. X}
  1784. X
  1785. X# endif
  1786. END_OF_FILE
  1787. if test 1614 -ne `wc -c <'prcpu.c'`; then
  1788.     echo shar: \"'prcpu.c'\" unpacked with wrong size!
  1789. fi
  1790. # end of 'prcpu.c'
  1791. fi
  1792. if test -f 'prheader.c' -a "${1}" != "-c" ; then 
  1793.   echo shar: Will not clobber existing file \"'prheader.c'\"
  1794. else
  1795. echo shar: Extracting \"'prheader.c'\" \(683 characters\)
  1796. sed "s/^X//" >'prheader.c' <<'END_OF_FILE'
  1797. X# ifndef lint
  1798. static char SccsId[] =  "@(#)prheader.c    1.1\t10/1/88" ;
  1799. X# endif
  1800. X
  1801. X# include       "sps.h"
  1802. X# include       "flags.h"
  1803. X
  1804. X/* PRHEADER - Print a header according to the switches */
  1805. prheader ()
  1806. X{
  1807. X    extern struct flags     Flg ;
  1808. X
  1809. X    printf( "Ty User    %s Proc#", Flg.flg_v ?
  1810. X# ifdef SUNOS40
  1811. X# ifdef OLDSTATS
  1812. X        " Status Fl Nice Virt Res %M  Time Child %C" :
  1813. X# else
  1814. X        " Status Fl Nice Prv  Shr  Res %M  Time Child %C" :
  1815. X# endif
  1816. X# else
  1817. X        " Status Fl Nice Virtual Resident %M  Time Child %C" :
  1818. X# endif
  1819. X        Flg.flg_d ?
  1820. X        "  Files    PageFaults Swap BlockI/O Kbytsecs" : "" ) ;
  1821. X    if ( Flg.flg_f )
  1822. X        printf( " Ppid#" ) ;
  1823. X    if ( Flg.flg_g )
  1824. X        printf( " Pgrp#" ) ;
  1825. X    printf( " Command\n" ) ;
  1826. X}
  1827. END_OF_FILE
  1828. if test 683 -ne `wc -c <'prheader.c'`; then
  1829.     echo shar: \"'prheader.c'\" unpacked with wrong size!
  1830. fi
  1831. # end of 'prheader.c'
  1832. fi
  1833. if test -f 'printall.c' -a "${1}" != "-c" ; then 
  1834.   echo shar: Will not clobber existing file \"'printall.c'\"
  1835. else
  1836. echo shar: Extracting \"'printall.c'\" \(509 characters\)
  1837. sed "s/^X//" >'printall.c' <<'END_OF_FILE'
  1838. X# ifndef lint
  1839. static char SccsId[] =  "@(#)printall.c    1.1\t10/1/88" ;
  1840. X# endif
  1841. X
  1842. X# include       <stdio.h>
  1843. X# include       "sps.h"
  1844. X
  1845. X/* PRINTALL - Recursively print the process tree. */
  1846. printall ( p, md )
  1847. X
  1848. register struct process         *p ;
  1849. register int                    md ;
  1850. X
  1851. X{
  1852. X    while ( p )
  1853. X    {       /* Print this process */
  1854. X        printproc( p, md ) ;    
  1855. X        (void)fflush( stdout ) ;
  1856. X        /* Print child processes */
  1857. X        printall( p->pr_child, md+1 ) ;
  1858. X        /* Print brother processes */
  1859. X        p = p->pr_sibling ;     
  1860. X    }
  1861. X}
  1862. END_OF_FILE
  1863. if test 509 -ne `wc -c <'printall.c'`; then
  1864.     echo shar: \"'printall.c'\" unpacked with wrong size!
  1865. fi
  1866. # end of 'printall.c'
  1867. fi
  1868. if test -f 'prsummary.c' -a "${1}" != "-c" ; then 
  1869.   echo shar: Will not clobber existing file \"'prsummary.c'\"
  1870. else
  1871. echo shar: Extracting \"'prsummary.c'\" \(712 characters\)
  1872. sed "s/^X//" >'prsummary.c' <<'END_OF_FILE'
  1873. X# ifndef lint
  1874. static char SccsId[] =  "@(#)prsummary.c    1.1\t10/1/88" ;
  1875. X# endif
  1876. X
  1877. X# include       "sps.h"
  1878. X
  1879. X/* PRSUMMARY - Print the summarising information */
  1880. prsummary ()
  1881. X{
  1882. X    extern struct summary   Summary ;
  1883. X
  1884. X    printf(
  1885. X"%D (%Dk) processes, %D (%Dk) busy, %D (%Dk) loaded, %D (%Dk) swapped\n",
  1886. X        Summary.sm_ntotal, KBYTES( Summary.sm_ktotal ),
  1887. X        Summary.sm_nbusy, KBYTES( Summary.sm_kbusy ),
  1888. X        Summary.sm_nloaded, KBYTES( Summary.sm_kloaded ),
  1889. X        Summary.sm_nswapped, KBYTES( Summary.sm_kswapped ) ) ;
  1890. X    Summary.sm_ntotal = 0L ;
  1891. X    Summary.sm_ktotal = 0L ;
  1892. X    Summary.sm_nbusy = 0L ;
  1893. X    Summary.sm_kbusy = 0L ;
  1894. X    Summary.sm_nloaded = 0L ;
  1895. X    Summary.sm_kloaded = 0L ;
  1896. X    Summary.sm_nswapped = 0L ;
  1897. X    Summary.sm_kswapped = 0L ;
  1898. X}
  1899. END_OF_FILE
  1900. if test 712 -ne `wc -c <'prsummary.c'`; then
  1901.     echo shar: \"'prsummary.c'\" unpacked with wrong size!
  1902. fi
  1903. # end of 'prsummary.c'
  1904. fi
  1905. if test -f 'readstatus.c' -a "${1}" != "-c" ; then 
  1906.   echo shar: Will not clobber existing file \"'readstatus.c'\"
  1907. else
  1908. echo shar: Extracting \"'readstatus.c'\" \(1281 characters\)
  1909. sed "s/^X//" >'readstatus.c' <<'END_OF_FILE'
  1910. X# ifndef lint
  1911. static char SccsId[] =  "@(#)readstatus.c    1.1\t10/1/88" ;
  1912. X# endif
  1913. X
  1914. X# include       "sps.h"
  1915. X# ifndef SUNOS40
  1916. X# include       <h/text.h>
  1917. X# endif
  1918. X
  1919. X/* READSTATUS - Reads the kernel memory for current processes and texts */
  1920. X# ifdef SUNOS40
  1921. readstatus ( process )
  1922. X
  1923. register struct process         *process ;
  1924. X
  1925. X# else
  1926. X
  1927. readstatus ( process, text )
  1928. X
  1929. register struct process         *process ;
  1930. struct text                     *text ;
  1931. X
  1932. X# endif
  1933. X{
  1934. X    register struct proc    *p ;
  1935. X    register struct proc    *p0 ;
  1936. X    register struct process *pr ;
  1937. X    int                     size ;
  1938. X    extern struct info      Info ;
  1939. X    char                    *getcore() ;
  1940. X
  1941. X# ifndef SUNOS40
  1942. X    /* Read current text information */
  1943. X    size = Info.i_ntext * sizeof( struct text ) ;
  1944. X    if ( getkmem( (long)Info.i_text0, (char*)text, size ) != size )
  1945. X        prexit( "sps - Can't read system text table\n" ) ;
  1946. X# endif
  1947. X    /* Read current process information */
  1948. X    size = Info.i_nproc * sizeof( struct proc ) ;
  1949. X    p0 = (struct proc*)getcore( size ) ;
  1950. X    if ( getkmem( (long)Info.i_proc0, (char*)p0, size ) != size )
  1951. X        prexit( "sps - Can't read system process table\n" ) ;
  1952. X    /* Copy process information into our own array */
  1953. X    for ( p = p0, pr = process ; pr < &process[ Info.i_nproc ] ; p++, pr++ )
  1954. X        pr->pr_p = *p ;
  1955. X    free( (char*)p0 ) ;
  1956. X}
  1957. END_OF_FILE
  1958. if test 1281 -ne `wc -c <'readstatus.c'`; then
  1959.     echo shar: \"'readstatus.c'\" unpacked with wrong size!
  1960. fi
  1961. # end of 'readstatus.c'
  1962. fi
  1963. if test -f 'selectproc.c' -a "${1}" != "-c" ; then 
  1964.   echo shar: Will not clobber existing file \"'selectproc.c'\"
  1965. else
  1966. echo shar: Extracting \"'selectproc.c'\" \(2248 characters\)
  1967. sed "s/^X//" >'selectproc.c' <<'END_OF_FILE'
  1968. X# ifndef lint
  1969. static char SccsId[] =  "@(#)selectproc.c    1.2\t6/15/90" ;
  1970. X# endif
  1971. X
  1972. X# include       "sps.h"
  1973. X# include       "flags.h"
  1974. X# ifdef USELOGINUID
  1975. X# include    <pwd.h>
  1976. X# endif USELOGINUID
  1977. X
  1978. X/*
  1979. X** SELECTPROC - Given a process structure, this procedure decides whether
  1980. X** the process is a candidate for printing.
  1981. X*/
  1982. selectproc ( p, process, thisuid )
  1983. X
  1984. register struct process         *p ;            
  1985. register struct process         *process ;      
  1986. int                thisuid ;
  1987. X
  1988. X{
  1989. X    register union flaglist *fp ;
  1990. X    register struct process *pp ;
  1991. X#ifdef USELOGINUID
  1992. X    char            *username ;
  1993. X    struct passwd        *pw ;
  1994. X    char            *getlogin() ;
  1995. X    struct passwd        *getpwnam() ;
  1996. X#endif USELOGINUID
  1997. X    extern struct flags     Flg ;
  1998. X
  1999. X    /* Flg.flg_AZ is an internal flag set if one of flags `A' to `Z'
  2000. X       was specified. If this is not set, a process is listed only
  2001. X       if it or one of its ancestors belongs to the invoking user. */
  2002. X    if ( !Flg.flg_AZ )
  2003. X    {
  2004. X#ifdef USELOGINUID
  2005. X        thisuid = (username = getlogin())
  2006. X            && (pw = getpwnam( username )) ? pw->pw_uid : getuid() ;
  2007. X#endif USELOGINUID
  2008. X        for ( pp = p ; pp > &process[1] ; pp = pp->pr_pptr )
  2009. X            if ( thisuid == pp->pr_p.p_uid )
  2010. X                return ( 1 ) ;
  2011. X    }
  2012. X    if ( Flg.flg_A )
  2013. X        return ( 1 ) ;
  2014. X    if ( Flg.flg_P )
  2015. X        for ( fp = Flg.flg_Plist ; fp->f_pid >= 0 ; fp++ )
  2016. X            if ( fp->f_pid == p->pr_p.p_pid )
  2017. X                return ( 1 ) ;
  2018. X    if ( Flg.flg_U )
  2019. X        for ( pp = p ; pp > &process[1] ; pp = pp->pr_pptr )
  2020. X            for ( fp = Flg.flg_Ulist ; fp->f_uid >= 0 ; fp++ )
  2021. X                if ( fp->f_uid == pp->pr_p.p_uid )
  2022. X                    return ( 1 ) ;
  2023. X    switch ( p->pr_p.p_stat )
  2024. X    {
  2025. X        case SRUN :
  2026. X            if ( Flg.flg_B )
  2027. X# ifdef SUNOS40
  2028. X                /* Ignore the idle processes */
  2029. X                return ( p->pr_p.p_pid != 3
  2030. X                    && p->pr_p.p_pid != 4 ) ;
  2031. X# else
  2032. X                return ( 1 ) ;
  2033. X# endif SUNOS40
  2034. X            break ;
  2035. X        case SSLEEP :
  2036. X            if ( Flg.flg_B
  2037. X            &&   p->pr_p.p_pri < PZERO && p->pr_p.p_pid > MSPID )
  2038. X# ifdef SUNOS40
  2039. X                /* Ignore the idle processes */
  2040. X                return ( p->pr_p.p_pid != 3
  2041. X                    && p->pr_p.p_pid != 4 ) ;
  2042. X# else
  2043. X                return ( 1 ) ;
  2044. X# endif SUNOS40
  2045. X        case SWAIT :
  2046. X        case SIDL :
  2047. X            if ( Flg.flg_W )
  2048. X                return ( 1 ) ;
  2049. X            break ;
  2050. X        case SSTOP :
  2051. X            if ( Flg.flg_S )
  2052. X                return ( 1 ) ;
  2053. X            break ;
  2054. X        case SZOMB :
  2055. X            if ( Flg.flg_Z )
  2056. X                return ( 1 ) ;
  2057. X            break ;
  2058. X        default :
  2059. X            break ;
  2060. X    }
  2061. X    return ( 0 ) ;
  2062. X}
  2063. END_OF_FILE
  2064. if test 2248 -ne `wc -c <'selectproc.c'`; then
  2065.     echo shar: \"'selectproc.c'\" unpacked with wrong size!
  2066. fi
  2067. # end of 'selectproc.c'
  2068. fi
  2069. if test -f 'selecttty.c' -a "${1}" != "-c" ; then 
  2070.   echo shar: Will not clobber existing file \"'selecttty.c'\"
  2071. else
  2072. echo shar: Extracting \"'selecttty.c'\" \(448 characters\)
  2073. sed "s/^X//" >'selecttty.c' <<'END_OF_FILE'
  2074. X# ifndef lint
  2075. static char SccsId[] =  "@(#)selecttty.c    1.1\t10/1/88" ;
  2076. X# endif
  2077. X
  2078. X# include       "sps.h"
  2079. X# include       "flags.h"
  2080. X
  2081. X/* SELECTTTY - Decides whether this process is interesting for its tty */
  2082. selecttty ( p )
  2083. X
  2084. register struct process         *p ;
  2085. X
  2086. X{
  2087. X    register union flaglist *fp ;
  2088. X    extern struct flags     Flg ;
  2089. X
  2090. X    for ( fp = Flg.flg_Tlist ; fp->f_ttyline ; fp++ )
  2091. X        if ( fp->f_ttyline == p->pr_tty )
  2092. X            return ( 1 ) ;
  2093. X    return ( 0 ) ;
  2094. X}
  2095. END_OF_FILE
  2096. if test 448 -ne `wc -c <'selecttty.c'`; then
  2097.     echo shar: \"'selecttty.c'\" unpacked with wrong size!
  2098. fi
  2099. # end of 'selecttty.c'
  2100. fi
  2101. if test -f 'termwidth.c' -a "${1}" != "-c" ; then 
  2102.   echo shar: Will not clobber existing file \"'termwidth.c'\"
  2103. else
  2104. echo shar: Extracting \"'termwidth.c'\" \(978 characters\)
  2105. sed "s/^X//" >'termwidth.c' <<'END_OF_FILE'
  2106. X# ifndef lint
  2107. static char SccsId[] =  "@(#)termwidth.c    1.3\t8/6/90" ;
  2108. X# endif
  2109. X
  2110. X# include    <sys/ioctl.h>
  2111. X
  2112. X/*
  2113. X** TERMWIDTH - Sets the external variable `Termwidth' to the # of columns
  2114. X** on the terminal.
  2115. X*/
  2116. termwidth ()
  2117. X{
  2118. X    register char           *termtype ;
  2119. X    register int            twidth ;
  2120. X# ifdef TIOCGWINSZ
  2121. X    struct winsize        w ;
  2122. X# else
  2123. X# ifdef TIOCGSIZE
  2124. X    struct ttysize          w ;
  2125. X# endif
  2126. X# endif
  2127. X    char                    buf[ 1025 ] ;
  2128. X    extern unsigned         Termwidth ;
  2129. X    char                    *getenv() ;
  2130. X
  2131. X# ifdef TIOCGWINSZ
  2132. X    w.ws_col = 0 ;
  2133. X    if ( !ioctl( 0, TIOCGWINSZ, &w ) && w.ws_col )
  2134. X    {
  2135. X        Termwidth = w.ws_col ;
  2136. X        return ;
  2137. X    }
  2138. X# else
  2139. X# ifdef TIOCGSIZE
  2140. X    w.ts_cols = 0 ;
  2141. X    if ( !ioctl( 0, TIOCGSIZE, &w ) && w.ts_cols )
  2142. X    {
  2143. X        Termwidth = w.ts_cols ;
  2144. X        return ;
  2145. X    }
  2146. X# endif
  2147. X# endif
  2148. X    Termwidth = 80 ;
  2149. X    if ( !(termtype = getenv( "TERM" )) )
  2150. X        return ;
  2151. X    if ( tgetent( buf, termtype ) != 1 )
  2152. X        return ;
  2153. X    twidth = tgetnum( "co" ) ;
  2154. X    if ( twidth > 40 )
  2155. X        Termwidth = twidth ;
  2156. X}
  2157. END_OF_FILE
  2158. if test 978 -ne `wc -c <'termwidth.c'`; then
  2159.     echo shar: \"'termwidth.c'\" unpacked with wrong size!
  2160. fi
  2161. # end of 'termwidth.c'
  2162. fi
  2163. if test -f 'vmstat.c' -a "${1}" != "-c" ; then 
  2164.   echo shar: Will not clobber existing file \"'vmstat.c'\"
  2165. else
  2166. echo shar: Extracting \"'vmstat.c'\" \(1902 characters\)
  2167. sed "s/^X//" >'vmstat.c' <<'END_OF_FILE'
  2168. X# ifndef lint
  2169. static char SccsId[] =  "@(#)vmstat.c    1.1\t10/1/88" ;
  2170. X# endif
  2171. X
  2172. X# ifdef SUNOS40
  2173. X# ifndef OLDSTATS
  2174. X# include "sps.h"
  2175. X# include <h/mman.h>
  2176. X# include <vm/hat.h>
  2177. X# include <vm/as.h>
  2178. X# include <vm/seg.h>
  2179. X# include <vm/seg_vn.h>
  2180. X
  2181. seg_count ( p )
  2182. X
  2183. struct process                  *p ;
  2184. X
  2185. X{
  2186. X    extern struct info      Info ;
  2187. X    struct as               as ;        /* address space */
  2188. X    struct seg              seg ;        /* segment in addr space */
  2189. X    struct segvn_data       vn_data ;
  2190. X    unsigned                private = 0 ;
  2191. X    unsigned                shared = 0 ;
  2192. X
  2193. X    p->pr_private = 0 ;
  2194. X    p->pr_shared = 0 ;
  2195. X
  2196. X    if ( getkmem( (long)p->pr_p.p_as, &as, sizeof( as ) ) != sizeof( as ) )
  2197. X        return( -1 ) ;
  2198. X    seg.s_next = as.a_segs ;    /* setup for loop */
  2199. X    do
  2200. X    {
  2201. X        if ( ( getkmem( seg.s_next, &seg, sizeof( seg ) ) )
  2202. X        != sizeof( seg ) )
  2203. X            break ;
  2204. X        if ( seg.s_as != p->pr_p.p_as )
  2205. X            continue ;    /* invalid segment */
  2206. X        if ( seg.s_ops != Info.i_segvn_ops )
  2207. X        {            /* mapped device is "shared" */
  2208. X            shared += seg.s_size ;
  2209. X            continue ;
  2210. X        }
  2211. X        if ( getkmem( (long)seg.s_data, &vn_data, sizeof( vn_data ) )
  2212. X        != sizeof( vn_data ) )
  2213. X            continue ;
  2214. X        /*
  2215. X         * If a segment has an anonymous mapping, it is in the swap
  2216. X         * area.  If it is also MAP_PRIVATE, we consider it "private"
  2217. X         * (even though it may be shared between parent and child after
  2218. X         * a fork() call).  Segments without an anonymous mapping are
  2219. X         * considered to be "shared".  [Should we worry about swap
  2220. X         * space reserved for copy-on-write shared segments?]
  2221. X         */
  2222. X
  2223. X        if ( vn_data.amp && (vn_data.type & MAP_TYPE) == MAP_PRIVATE )
  2224. X            private += seg.s_size ;
  2225. X        else
  2226. X            shared += seg.s_size ;
  2227. X    }
  2228. X    while ( seg.s_next != as.a_segs ) ;
  2229. X
  2230. X# define BYTETOPAGE(x) (((x)+(PAGESIZE-1))>>PGSHIFT)
  2231. X
  2232. X    p->pr_private = BYTETOPAGE( private ) ;
  2233. X    p->pr_shared = BYTETOPAGE( shared ) ;
  2234. X    p->pr_p.p_rssize = as.a_rss ;    /* update count of resident pages */
  2235. X    return( 0 ) ;
  2236. X}
  2237. X# endif
  2238. X# endif
  2239. END_OF_FILE
  2240. if test 1902 -ne `wc -c <'vmstat.c'`; then
  2241.     echo shar: \"'vmstat.c'\" unpacked with wrong size!
  2242. fi
  2243. # end of 'vmstat.c'
  2244. fi
  2245. echo shar: End of archive 1 \(of 3\).
  2246. cp /dev/null ark1isdone
  2247. MISSING=""
  2248. for I in 1 2 3 ; do
  2249.     if test ! -f ark${I}isdone ; then
  2250.     MISSING="${MISSING} ${I}"
  2251.     fi
  2252. done
  2253. if test "${MISSING}" = "" ; then
  2254.     echo You have unpacked all 3 archives.
  2255.     rm -f ark[1-9]isdone
  2256. else
  2257.     echo You still need to unpack the following archives:
  2258.     echo "        " ${MISSING}
  2259. fi
  2260. ##  End of shell archive.
  2261. exit 0
  2262.