[comp.sys.amiga] AmigaMonitor

shf@solar.STANFORD.EDU (Stuart Ferguson) (04/30/87)

Regarding the program AmigaMonitor:  Is there source available?

I'd like to have a "who"-like or "ps"-like utility on the Amiga to show all
processes, even the "private" ones.  AmigaMonitor is nice but seems a bit
overkill.  Is there such a utility available or is the source for 
AmigaMonitor available for me to hack on?

	- Tanx in advance,
	Stuart		shf@solar.Stanford.EDU

hsgj@batcomputer.tn.cornell.edu (Dan Green) (05/02/87)

In article <1556@solar.STANFORD.EDU> shf@solar.UUCP (Stuart Ferguson) writes:
>Regarding the program AmigaMonitor:  Is there source available?
>
>I'd like to have a "who"-like or "ps"-like utility on the Amiga to show all
>processes, even the "private" ones.  AmigaMonitor is nice but seems a bit
>overkill.  Is there such a utility available or is the source for 
>AmigaMonitor available for me to hack on?
>
>	- Tanx in advance,
>	Stuart		shf@solar.Stanford.EDU


About 6 months ago (I think) someone whose name I have lost (see below)
posted the source and executable for a PS program that told you about
all processes running, not just about CLI jobs.  I think this is probably
what you want.

The problem is that I transferred it from this unix-machine to the Amiga
via a simple capture, as that was in the days before I had Amiga-Kermit
or VT100, etc.  I didn't notice it at the time, but the file had a severe
attack of line noise, etc.  Well, to cut short this prelude, I deleted
all copies of ps from this unix machine, plus the posting expired, before
I discovered the corruption on the Amiga version.

So I had to rewite PS pretty much from the mangled version I had.
This particular version, then, was compiled with Lattice 3.03 and
then BLINKed with Astartup.obj, amiga.lib and finally lc.lib.
This made a pretty small executable, as you can see.

The last point that I want to reiterate is that this was inspired from
someone whose name I don't have, do to the problems mentioned; so if he
wants to say he wrote it first then he should announce his presence
and take his due credits.
-- Dan Green (beware of .sig at eof)

# ------------------ Cut here -------------------------------------
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "/bin/sh file".
#
# Wrapped by hsgj@tcgould.tn.cornell.edu on Fri May  1 20:48:08 EDT 1987
# Contents:  ps.c ps.uue
 
echo x - ps.c
sed 's/^@//' > "ps.c" <<'@//E*O*F ps.c//'
#include "exec/types.h"
#include "exec/execbase.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "exec/tasks.h"

#define	HIDDEN		static
#define	MAXTASKS	100

struct	ExecBase	*ExecBase;

HIDDEN	char	*names[MAXTASKS];
HIDDEN	BYTE	prty[MAXTASKS];
HIDDEN	UBYTE	state[MAXTASKS];

VOID	display(count)
int	count;
{
	int	i;
	char	*stext;

	for (i = 0; i < count; i++) {
		switch (state[i]) {
			case 0:
				stext = "Invalid ";
				break;
			case 1:
				stext = "Added   ";
				break;
			case 2:
				stext = "Run     ";
				break;
			case 3:
				stext = "Ready   ";
				break;
			case 4:
				stext = "Wait    ";
				break;
			case 5:
				stext = "Except  ";
				break;
			case 6:
				stext = "Removed ";
				break;
			default:
				stext = "Unknown ";
				break;
		}
		printf(" %ld	  %ls %ls\n",prty[i],stext,names[i]);
	}
}

main()
{
	struct	Task	*task;
	int	count;

	if ((ExecBase = (struct ExecBase *)
		OpenLibrary("exec.library",0)) == 0) {
		printf("Couldn't open Exec Library\n");
		return(0);
	}
	printf("\033[4mPriority\033[m  \033[4mState\033[m    \033[4mName\033[m\n");

	count = 0;
	Disable();
	names[0] = ExecBase->ThisTask->tc_Node.ln_Name;
	prty[0] = ExecBase->ThisTask->tc_Node.ln_Pri;
	state[0] = ExecBase->ThisTask->tc_State;
	Enable();
	display(1);

	count = 0;
	Disable();
	for (task = (struct Task *)ExecBase->TaskReady.lh_Head;
		task->tc_Node.ln_Succ;
		task = (struct Task *)task->tc_Node.ln_Succ) {
		names[count] = task->tc_Node.ln_Name;
		state[count] = task->tc_State;
		prty[count++] = task->tc_Node.ln_Pri;
	}
	Enable();
	display(count);

	count = 0;
	Disable();
	for (task = (struct Task *)ExecBase->TaskWait.lh_Head;
		task->tc_Node.ln_Succ;
		task = (struct Task *)task->tc_Node.ln_Succ) {
		names[count] = task->tc_Node.ln_Name;
		state[count] = task->tc_State;
		prty[count++] = task->tc_Node.ln_Pri;
	}
	Enable();
	display(count);

	CloseLibrary(ExecBase);
}
@//E*O*F ps.c//
chmod u=rw,g=r,o=r ps.c
 
echo x - ps.uue
sed 's/^@//' > "ps.uue" <<'@//E*O*F ps.uue//'
begin 0 ps
M   #\P         *          D    "    <0   &X   ".    +    )< 
M   4    "     \    3   #Z0    ).^0           ^P    !     0  
M  (        #\@   ^D   !Q(\\    <(\     D(\@    H0KD    @+'D 
M   $(\X    $D\E.KO[:*$!*K "L9P  J&$  6P@; "LT<C1R"!H !#1R-'(
M2.<@,$7Y    K$?Y    +'0!<  0&";*8 (4V%'(__Q"&B Y    )"!Y    
M*!(84X!O'@P! "!O]%*")LI@"A(84X , 0 @;P04P6#R0AI@W$(:0IL@ DS?
M# 1(>0   "PO $ZY    '"/     $$ZY    +"/     %"/     &$ZY    
MS'  +GD    <3G5A  #&80  L"/     ($*G+P D0" J "1G$"QY    ""! 
M(B@  $ZN_X(B*@ @9R@D/    ^U.KO_B(\     0(\     4(\     89PKE
MB"! *6@ " "D3KD   #,< !@!" O  0N>0   !PO "QY    !" Y    "&<"
M(D!.KOYB2KD    @9PY.KO]\(GD    @3J[^AB ?3G5(YP$&+CP  X '+'@ 
M!$ZN_Y1,WV" <&1@L$'L %Q.KOZ 0>P 7$ZN_HQ.=4*Y    "$/Y   !K" \
M    'DZN_=@CP     AGMDYU      /L    &@    (   &Z   !J@   :0 
M  %J   !7@   5    %"   !(@   1P   $6    ]@   .0   #4    Q@  
M ,    "T    I@   '(   !L    5    $X    @    %     X    (    
M @    (    #   !-    ,P    "    "    *X   "Z         _(   /J
M    ;@ !                                                    
M                                                            
M                                                            
M                                                            
M                                                            
M                                                            
M                                                            
M                                                            
M                                                            
M                                    9&]S+FQI8G)A<GD    #\@  
M ^D   ".3E;_^$*N__P@+O_\L*X "&P  +8@0-'\   !^'  $! ,@     =D
M6N. 3OL( F ,8!1@'& D8"Q@-& \+7P     __A@1"U\    "?_X8#HM?   
M !+_^& P+7P    ;__A@)BU\    )/_X8!PM?    "W_^& 2+7P    V__A@
M""U\    /__X(&[__-'\   !E! 02(!(P"(N__SE@2!!T?P    $+Q O+O_X
M+P!(>0   $A.N0    !/[P 04J[__&  _T).7DYU3E;_^$*G2'D   !83KD 
M   T4(\CP     !*@&842'D   !E3KD     6(]P $Y>3G5(>0   (%.N0  
M  !8CT*N__A.N0     B>0     @:0$4(^@ "@    03Z  )   !E!/H  \ 
M  'X3KD    0< $O &$ _KQ8CT*N__A.N0     @>0     M: &6__P@;O_\
M2I!G0" N__CE@"! T?P    $(F[__""I  H@;O_XT?P   'X$*D #R!N__C1
M_    912KO_X$*D "2!N__PM4/_\8+A.N0   ! O+O_X80#^3EB/0J[_^$ZY
M     "!Y     "UH :3__"!N__Q*D&= ("[_^.6 ($#1_     0B;O_\(*D 
M"B!N__C1_    ?@0J0 /(&[_^-'\   !E%*N__@0J0 )(&[__"U0__Q@N$ZY
M    $"\N__AA /W@6(\O.0    !.N0   "!8CTY>3G4      ^P    ,    
M!    0    #L    U    +(   "$    >@   '    !F    7    %(   !(
M    /@   !$    %   ")@   ?X   'P   !W@   <(   &0   !@@   7  
M  %4   !-    2P   $D   !&    .(   "D    D    !@    #    !P  
M 08   #R    N     @    )   "+    A8   &H   !.@   ;P   %.   !
M$@   -H        #\@   ^H    L26YV86QI9"  061D960@("  4G5N(" @
M("  4F5A9'D@("  5V%I=" @("  17AC97!T("  4F5M;W9E9"  56YK;F]W
M;B  ("5L9 D@("5L<R E;',* &5X96,N;&EB<F%R>0!#;W5L9&XG="!O<&5N
M($5X96,@3&EB<F%R>0H &ULT;5!R:6]R:71Y&UMM(" ;6S1M4W1A=&4;6VT@
M(" @&ULT;4YA;64;6VT*      /R   #ZP   )<   /R   #Z0   !1(YP Z
M*&\ %"!O !@B;P <1?H .D_O_W0F3RQY    !$ZN_?9P_TH;5\C__$: 9Q(O
M $AO  1(5$ZY     $_O  Q/[P",3-]< $YU%L!.=0   ^P    !    "   
M #H        #\@   ^D    (+P(D+P (2&\ #"\"+SD    43KD     3^\ 
M#"0?3G4   /L     0    (    .     0    8    4         _(   /I
M    #TCG, (L>0    A,[P . !!.KO_03-] #$YU   O#BQY    "$ZN_\HL
M7TYU+PXL>0    A.KO_$+%].=0   ^P    #     @   #     @    !@  
M      /R   #Z0   !,O#BQY    !$ZN_X@L7TYU+PXL>0    1.KO^"+%].
M=2\.+'D    $(F\ "$ZN_F(L7TYU+PXL>0    0B;P (("\ #$ZN_=@L7TYU
D   #[     0    "    .    "0    4    !         /R
 
end
@//E*O*F ps.uue//
chmod u=rw,g=r,o=r ps.uue
 
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
      98     212    1896 ps.c
      60     413    3539 ps.uue
     158     625    5435 total
!!!
wc  ps.c ps.uue | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0
-- 
ARPA:  hsgj@tcgould.tn.cornell.edu
UUCP:  ihnp4!cornell!batcomputer!hsgj   BITNET:  hsgj@cornella