<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
                               					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page   1
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0001    	PROGRAM		WATCH_DOG
0002    	IMPLICIT NONE
0003    C
0004    C   Program:	WATCHDOG
0005    C
0006    C   Original:	unknown (program came from Decus Tape)
0007    C
0008    C   Modifier's Address:
0009    C		George H. Walrod III   Phone: (301) 251-8485
0010    C		MS-34
0011    C		1801 Research Boulevard
0012    C		Rockville, MD 20850
0013    C
0014    C   Purpose:	This Program Monitors Interactive Processes and Logs Off
0015    C		Processes Set There Idle.
0016    C
0017    C   Compilation:	&lt;WATCHDOG.BLD&gt;
0018    C		FORTRAN /CONTINUATION=99/LIST/CROSS WATCHDOG
0019    C		MACRO WATCHSYM
0020    C		LINK WATCHDOG,WATCHSYM/SELECTIVE/NOTRACEBACK/MAP
0021    C
0022    C   Other Modules:
0023    C		WATCHSYM.MAR	- System Symbols for Watch Dog
0024    C
0025    C   Corrected Modification:
0026    C		Restructured Program adding comments and Fixing a Bug
0027    C		if you login into another System using Decnet
0028    C		you idle on Host but still working on other system.
0029    C					04/06/85	George H. Walrod III
0030    C
0031    C		Correct Bug if User Spawns a Subprocess the Subprocess
0032    C		Does not Have a Terminal when you do a GETJPI, so we
0033    C		Search for the Parent Process to Get the Terminal.  If
0034    C		Parent has No Terminal They are probley a Detach Process
0035    C		and We Do Not Tough thoses Process.
0036    C					04/22/85	George H. Walrod III
0037    C
0038    C		Security/Bug, If user Spawn a Subprocess and then
0039    C		Suspends his Parent Process, Then we can't find his
0040    C		Terminal.  The User seems to be trying to avoid Watchdog
0041    C		So we warning him but send no Messages, and eventually
0042    C		log him off, Knowing That it will probley hang him in
0043    C		Suspended Process.  But we try to resume the Parent
0044    C		Process first knowing that this will probably no work.
0045    C					04/22/85	George H. Walrod III
0046    C
0047    C		Watch Dog get hits by Car! When Watchdog tells the user
0048    C		that they are being logged off and the User logs out on
0049    C		their own, When Watch goes to bite(Delete) the user 
0050    C		process for the final Kill, and user is gone.  Watchdog
0051    C		dies when a car(Error) come from no where. The license
0052    C		plate of the car is "SS$_NONEXPR" (nonexistent process).
0053    C					04/26/85	George H. Walrod III

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page   2
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0054    C   Notes:
0055    C
0056    C	Variables of Some Importants :
0057    C		Maxuser		: Maximum Number of Users Program can Support
0058    C		Send_Stamp	: What Interval Time Stamp Should be Send
0059    C		Start_Message	: What Interval Cycle Should Warning Message
0060    C				  Starts.
0061    C		Stop_Message	: What Interval Cycle Should Process be Deleted
0062    C		ASCTIM		: Single Interval Cycle
0063    C
0064    C	Debugging Tools Build-in :
0065    C		D-Lines are used for Debug, note when you compile Watchdog
0066    C		with D_LINES only Processes with Group Number matching the
0067    C		System Group(variable name SYSGRP) will be monitored.
0068    C

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page   3
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0069    	PARAMETER
0070         +		MAXUSER		= 256,		! Maximum Number Users
0071         +		SEND_STAMP	= 6,		! Time Stamp(send_stamp*asctim)
0072         +		START_MESSAGE	= 1,		! Start Sending Warning Msg
0073         +		STOP_MESSAGE	= 2,		! Stop Process Msg
0074         +		JPI_WILDCARD	= -1,		! Get Job Process Info Wildcard
0075         +		EFN		= 1,		! Event Flag
0076         +		CPU_50MS	= 5,		! 50 MS Resolution
0077         +		SYSGRP		= 7,		! System Group Number
0078         +		UNKNOWN_TERM	= 'UNKN',	! Unknown Terminal Name
0079         +		PROCESS_NAME	= 'gATCHDOG',	! Process Name
0080         +		BELL		= char(7),	! Ascii Bell
0081         +		FAO_IN_STR	= 
0082         +			'!AS !AS on !AS has been inactive for !SL min.!/!AS',
0083         +		HEADER_MSG	= 		! Header Message
0084         +			BELL//'MESSAGE FROM WATCH_DOG'//BELL,
0085         +		STAMP_MSG	=		! Time Stamp Message
0086         +			'WATCH DOG TIME STAMP',
0087         +		LOGOFF_DEF	=		! DEFAULT LOGOFF
0088         +			' and is being Logged Off',
0089         +		INIT_MSG	=		! Initial Message
0090         +			'WATCH DOG HAS BEEN INITIALIZED AND IS RUNNING'
0091     
0092    	LOGICAL*1
0093         +		MS_TYPE,			! Operator Request Type
0094         +		OPER_MSG_BUF(8),		! Operator Message Buffer
0095         +		STOPABLE(MAXUSER),		! Process Stopable
0096         +		NO_WARNING			! Send No Warning Message
0097     
0098    	CHARACTER
0099         +		ACCNAM*8,			! Account Name
0100         +		TIMBF*8,			! Current Time Buffer
0101         +		TTYNUM*7,			! Terminal Name
0102         +		USRNAM*12,			! User Name
0103         +		LOGOFF_MSG*24,			! Logoff Message
0104         +		MESSAGE*85,			! Message Buffer
0105         +		ASCTIM*13 /'0 00:01:00.00'/,	! Time Delay
0106         +		OPER_MESS*95			! Operator Message
0107     
0108    	INTEGER*2
0109         +		JPIBUF2(14),			! Job Process Info Buffer
0110         +		JPIBUF(62),			! Job Process Info Buffer
0111         +		SEQ_NUMBER(2),			! Sequence Number PID
0112         +		SEQ(MAXUSER)			! Sequence Part Of Pid

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page   4
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0113    	INTEGER*4
0114         +		MS_TARGET,			! Operator Terminal Type
0115         +		TIME_STAMP,			! Time Stamp Counter
0116         +		SEEDPID,			! Seed Pid for GETJPI
0117         +		CUR_PID,			! Current Pid
0118         +		BINTIM(2),			! Binary Time
0119         +		RANGE(2)	/0,'7FFFFFFF'X/,! Working Set Purge
0120         +		CPUTIM(MAXUSER),		! Cpu Time Used
0121         +		BUFIOC(MAXUSER),		! Number Of Buffer I/O
0122         +		WARNING(MAXUSER),		! Number Of Warning So Far
0123         +		SS_STATUS,			! Sys Service Status
0124         +		LIB$MATCHC,			! RTL Index for Colon
0125         +		OTS$CVT_TI_L,			! RTL Convert Decimal-&gt;Binary
0126         +		SYS$SETPRN,			! SS Set Process Name
0127         +		SYS$FAO,			! SS Format Ascii Output
0128         +		SYS$SCHDWK,			! SS Schedule Wake
0129         +		SYS$PURGWS,			! SS Purge Working set
0130         +		SYS$BINTIM,			! SS Binary Time
0131         +		SYS$DELPRC,			! SS Delete Process
0132         +		SYS$BRDCST,			! SS Broadcast
0133         +		SYS$SNDOPR,			! SS Send Operator
0134         +		SYS$GETJPI,			! SS Get Job Process Info
0135         +		SYS$WAITFR,			! SS Wait For Efn
0136         +		SYS$RESUME,			! SS Resume
0137         +		SYS$HIBER,			! SS Hiberate
0138         +		START_IDX,			! Index Pointer of TIME
0139         +		TIME_MINUTES,			! Time in Minutes
0140         +		MESSAGE_LEN,			! Message Length
0141         +		PID,				! Process Identifacation No.
0142         +		OWNER,				! Process Owner Pid
0143         +		NEWCPU,				! New Cpu Time
0144         +		NEWIOC,				! New Buffer I/O Count
0145         +		STATE,				! Process State
0146         +		GRPNUM,				! Group Number
0147         +		SUBCOUNT,			! Sub-Process Count
0148         +		PIDADDR,			! Addr of Pid
0149         +		PIDLEN,				! Length of Pid
0150         +		CPUTADDR,			! Addr of Cpu Time
0151         +		CPULEN,				! Length of Cpu Time
0152         +		BIOADDR,			! Addr Buffer I/O
0153         +		BIOLEN,				! Length Buffer I/O
0154         +		STATEADDR,			! Addr of Process State
0155         +		STATELEN,			! Length of Process State
0156         +		USRNAM_L,			! User Name Length
0157         +		USERADDR,			! Addr of User Name
0158         +		USERLEN,			! Length of User Name
0159         +		ACCNAM_L,			! Account Name Length
0160         +		ACCADDR,			! Addr of Account Name
0161         +		ACCLEN,				! Length of Account Name
0162         +		TTYNUM_L,			! Terminal Name Length
0163         +		TERMADDR,			! Addr of Terminal Name
0164         +		TERMLEN,			! Length of Terminal Name
0165         +		GRPADDR,			! Addr of Group Number
0166         +		GRPLEN,				! Length Group Number
0167         +		PRCCADDR,			! Addr of Process Count
0168         +		PRCCLEN,			! Length of Process Count
0169         +		OWNERADDR,			! Addr of Owner Pid

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page   5
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0170         +		OWNERLEN,			! Length of Owner Pid
0171         +		TERMADDR2,			! Addr of Terminal Name
0172         +		TERMLEN2,			! Length of Terminal Name
0173         +		OWNERADDR2,			! Addr of Owner Pid
0174         +		OWNERLEN2			! Length of Owner Pid

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page   6
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0175    	EXTERNAL
0176         +		SS$_DEVOFFLINE,			! Device Offline Line
0177         +		SS$_NOMOREPROC,			! No More Processes
0178         +		SS$_NONEXPR,			! Non Existent Process
0179         +		SS$_NORMAL,			! Normal Completion
0180         +		SS$_SUSPENDED,			! Process Suspended
0181         +		JPI$_PID,			! Pid
0182         +		JPI$_CPUTIM,			! Cpu Time
0183         +		JPI$_BUFIO,			! Buffer I/O
0184         +		JPI$_STATE,			! Process State
0185         +		JPI$_USERNAME,			! User Name
0186         +		JPI$_ACCOUNT,			! Account Name
0187         +		JPI$_TERMINAL,			! Terminal Name
0188         +		JPI$_GRP,			! Group Number
0189         +		JPI$_PRCCNT,			! Process Count
0190         +		JPI$_OWNER,			! Process Owner
0191         +		JPI$C_LISTEND,			! End List
0192         +		SCH$C_HIB,			! Schedule Hiberation
0193         +		SCH$C_HIBO,			! Schedule Hiberation Out Swap
0194         +		OPC$M_NM_CENTRL,		! Operator Central
0195         +		OPC$_RQ_RQST			! Operator Request

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page   7
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0196    C
0197    C   Define Equivalence Fields for Data Buffers
0198    C
0199    	EQUIVALENCE
0200         +		(PIDADDR,	JPIBUF(03)),
0201         +		(PIDLEN,	JPIBUF(05)),
0202         +		(CPUTADDR,	JPIBUF(09)),
0203         +		(CPULEN,	JPIBUF(11)),
0204         +		(BIOADDR,	JPIBUF(15)),
0205         +		(BIOLEN,	JPIBUF(17)),
0206         +		(STATEADDR,	JPIBUF(21)),
0207         +		(STATELEN,	JPIBUF(23)),
0208         +		(USERADDR,	JPIBUF(27)),
0209         +		(USERLEN,	JPIBUF(29)),
0210         +		(ACCADDR,	JPIBUF(33)),
0211         +		(ACCLEN,	JPIBUF(35)),
0212         +		(TERMADDR,	JPIBUF(39)),
0213         +		(TERMLEN,	JPIBUF(41)),
0214         +		(GRPADDR,	JPIBUF(45)),
0215         +		(GRPLEN,	JPIBUF(47)),
0216         +		(PRCCADDR,	JPIBUF(51)),
0217         +		(PRCCLEN,	JPIBUF(53)),
0218         +		(OWNERADDR,	JPIBUF(57)),
0219         +		(OWNERLEN,	JPIBUF(59)),
0220         +		(TERMADDR2,	JPIBUF2(03)),
0221         +		(TERMLEN2,	JPIBUF2(05)),
0222         +		(OWNERADDR2,	JPIBUF2(09)),
0223         +		(OWNERLEN2,	JPIBUF2(11)),
0224         +		(MS_TYPE,	OPER_MSG_BUF(1)),
0225         +		(MS_TARGET,	OPER_MSG_BUF(2)),
0226         +		(OPER_MSG_BUF,	OPER_MESS),
0227         +		(MESSAGE,	OPER_MESS(11:)),
0228         +		(SEQ_NUMBER(1),	PID)

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page   8
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0229    C
0230    C   Job Process Information Layout
0231    C						! +---------------+
0232    	JPIBUF(01) = 4				! |  Pid Buf Size |
0233    	JPIBUF(02) = %loc(jpi$_pid)		! |      PID      |
0234    	PIDADDR    = %loc(pid)			! |   Pid Addr    |
0235    	PIDLEN     = 0				! |  Pid Ret Len  |
0236    	JPIBUF(7)  = 4				! |  Cpu Time Len |
0237    	JPIBUF(8)  = %loc(jpi$_cputim)		! |    CPUTIM     |
0238    	CPUTADDR   = %loc(newcpu)		! | Cpu Time Addr |
0239    	CPULEN     = 0				! |  Cpu Ret Len  |
0240    	JPIBUF(13) = 4				! |  Buf I/O Size |
0241    	JPIBUF(14) = %loc(jpi$_bufio)		! |   Buffer I/O  |
0242    	BIOADDR    = %loc(newioc)		! | Buf I/O Addr  |
0243    	BIOLEN     = 0				! | BufIO Ret Len |
0244    	JPIBUF(19) = 4				! |Proc State Size|
0245    	JPIBUF(20) = %loc(jpi$_state)		! | Process State !
0246    	STATEADDR  = %loc(state)		! |Proc State Addr|
0247    	STATELEN   = 0				! | State Ret Len |
0248    	JPIBUF(25) = 12				! | User Name Len |
0249    	JPIBUF(26) = %loc(jpi$_username)	! |   User Name   |
0250    	USERADDR   = %loc(usrnam)		! | User Name Addr|
0251    	USERLEN    = %loc(usrnam_l)		! | User Ret Len  |
0252    	JPIBUF(31) = 8				! | Account Sizen |
0253    	JPIBUF(32) = %loc(jpi$_account)		! |    Account    |
0254    	ACCADDR    = %loc(accnam)		! | Account Addr  |
0255    	ACCLEN     = %loc(accnam_l)		! | Account Retlen|
0256    	JPIBUF(37) = 7				! | Terminal Size |
0257    	JPIBUF(38) = %loc(jpi$_terminal)	! |   Terminal    |
0258    	TERMADDR   = %loc(ttynum)		! | Terminal Addr |
0259    	TERMLEN    = %loc(ttynum_l)		! | Terminal Len  |
0260    	JPIBUF(43) = 4				! |  Grpno Size   |
0261    	JPIBUF(44) = %loc(jpi$_grp)		! | Group Number  |
0262    	GRPADDR    = %loc(grpnum)		! |  Grpno Addr   |
0263    	GRPLEN     = 0				! | Grpno Ret Len |
0264    	JPIBUF(49) = 4				! | Process Size  |
0265    	JPIBUF(50) = %loc(jpi$_prccnt)		! | Process Count |
0266    	PRCCADDR   = %loc(subcount)		! |   Proc Addr   |
0267    	PRCCLEN    = 0				! | Proc Ret Len  |
0268    	JPIBUF(55) = 4				! | Owner Size    |
0269    	JPIBUF(56) = %loc(jpi$_owner)		! |  Owner Pid    |
0270    	OWNERADDR  = %loc(owner)		! |  Owner Addr   |
0271    	OWNERLEN   = 0				! | Owner Ret Len |
0272    	JPIBUF(61) = %loc(jpi$c_listend)	! |  END OF LIST  |
0273    	JPIBUF(62) = %loc(jpi$c_listend)	! |  END OF LIST  |
0274    C						  +---------------+
0275    C   End of Job Process Information List
0276    C

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page   9
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0277    C
0278    C   Job Process Information Layout Subprocess
0279    C						! +---------------+
0280    	JPIBUF2(01) = 7				! | Terminal Size |
0281    	JPIBUF2(02) = %loc(jpi$_terminal)	! |   Terminal    |
0282    	TERMADDR2   = %loc(ttynum)		! | Terminal Addr |
0283    	TERMLEN2    = %loc(ttynum_l)		! | Terminal Len  |
0284    	JPIBUF2(07) = 4				! | Owner Size    |
0285    	JPIBUF2(08) = %loc(jpi$_owner)		! |  Owner Pid    |
0286    	OWNERADDR2  = %loc(owner)		! |  Owner Addr   |
0287    	OWNERLEN2   = 0				! | Owner Ret Len |
0288    	JPIBUF2(13) = %loc(jpi$c_listend)	! |  END OF LIST  |
0289    	JPIBUF2(14) = %loc(jpi$c_listend)	! |  END OF LIST  |
0290    C						  +---------------+
0291    C   End of Job Process Information List for Subprocess
0292    C

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  10
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0293    C
0294    C   Set-Up Data Buffer for Operator Message
0295    C
0296    	MS_TYPE   = %loc(OPC$_RQ_RQST)
0297    	MS_TARGET = %loc(OPC$M_NM_CENTRL)
0298    	OPER_MESS(9:10) = BELL // BELL
0299     
0300    C
0301    C   Convert Ascii Time to Binary Time
0302    C
0303     
0304    	SS_STATUS = SYS$BINTIM(ASCTIM,BINTIM)
0305    	IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))
0306     
0307    C
0308    C   Extract Minutes From Asctim for Warning Messages
0309    C
0310     
0311    	START_IDX = LIB$MATCHC(':',ASCTIM) + 1
0312 C  D	TYPE *,'ASCII Time Intervals is ',ASCTIM
0313 C  D	TYPE *,'Number of Minutes ASCII ',ASCTIM(START_IDX:START_IDX+1)
0314    	SS_STATUS = OTS$CVT_TI_L(ASCTIM(START_IDX:START_IDX+1),
0315         +							TIME_MINUTES)
0316 C  D	TYPE *,'Type Return Status from OTS$CVT_TI_L is ',SS_STATUS
0317    	IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))
0318     
0319    C
0320    C   Set Process Name to "WATCH_DOG"
0321    C
0322     
0323    	SS_STATUS = SYS$SETPRN(PROCESS_NAME)
0324    	IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  11
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0325    C
0326    C   Send Operator Console Message Tell Them That I am Running
0327    C
0328     
0329    	MESSAGE   = INIT_MSG
0330    	SS_STATUS = SYS$SNDOPR(OPER_MESS,)
0331 C  D	TYPE *,'Type Return Status from SYS$SNDOPR is ',SS_STATUS
0332    	IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))
0333     
0334    C
0335    C   Initialize Time Stamp Time So That I Send Time Stamp Message
0336    C   Too When I Start Running
0337    C
0338     
0339    	TIME_STAMP = SEND_STAMP - 1
0340     
0341    C
0342    C   Main Section of Program, Get Data on Users
0343    C
0344     
0345    1	CONTINUE
0346    	TIME_STAMP = TIME_STAMP + 1
0347    C
0348    C   Send Time Stamp Message If It is Time
0349    C
0350    	IF (TIME_STAMP .eq. SEND_STAMP ) then
0351    	  MESSAGE   = STAMP_MSG
0352    	  SS_STATUS = SYS$SNDOPR(OPER_MESS,)
0353 C  D	  TYPE *,'Type Return Status from SYS$SNDOPR is ',SS_STATUS
0354    	  IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))
0355    	  TIME_STAMP=0
0356    	ENDIF
0357    C
0358    C   Loop Until We Have Looked At All Processes using 
0359    C   Get Job Process Information with a Wild Card
0360    C
0361 C  D900	  FORMAT(' Working With PID ',Z8)
0362     
0363    	SEEDPID   = JPI_WILDCARD
0364    	SS_STATUS = 0
0365    	DO WHILE (SS_STATUS .ne. %loc(SS$_NOMOREPROC))
0366    	  SS_STATUS   = SYS$GETJPI(%val(EFN),%ref(SEEDPID),,%ref(JPIBUF),,,)
0367 C  D	  TYPE *,'Type Return Status from SYS$GETJPI is ',SS_STATUS
0368 C  D	  TYPE 900,PID
0369    	  IF (SS_STATUS) then
0370    	    SS_STATUS = SYS$WAITFR(%val(EFN))
0371    	   ELSE
0372    	    IF ((SS_STATUS .ne. %loc(SS$_NOMOREPROC)) .and.
0373         +		 SS_STATUS .ne. %loc(SS$_SUSPENDED)) then
0374    	      CALL LIB$STOP(%val(SS_STATUS))
0375    	     ELSE
0376    	      GOTO 20
0377    	     endif
0378    	   endif

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  12
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0379    C
0380    C   We Have A User, Get The Low 16 Bits Of His Pid (the index) 
0381    C   the High Order Bits Are the Sequence number
0382    C
0383     
0384    	  CUR_PID = SEQ_NUMBER(1)
0385     
0386    C
0387    C   If The Sequence Number Has Changed Since We Last Logged In,
0388    C   We Have A New Sucker. Reset All The Use Counts, And Dont Bother Him
0389    C
0390     
0391    	  IF (SEQ(CUR_PID) .ne. SEQ_NUMBER(2)) then
0392 C  D	    TYPE *,'Never Seen This Person Before'
0393    	    SEQ(CUR_PID)      = SEQ_NUMBER(2)
0394    	    WARNING(CUR_PID)  = 0
0395    	    STOPABLE(CUR_PID) = .TRUE.
0396    	    GOTO 10
0397    	   endif
0398     
0399    C
0400    C   Is The Process Subject to Watchdog Monitoring
0401    C	(am I wasteing my time)
0402    C
0403     
0404    	  IF (.not. STOPABLE(CUR_PID)) GOTO 10
0405     
0406    C
0407    C   Leave The Processes Alone, Which are Hiberating
0408    C
0409     
0410    	  IF ((STATE .eq. %loc(SCH$C_HIB)) .or.
0411         +	      (STATE .eq. %loc(SCH$C_HIBO))) GOTO 10
0412     
0413    C
0414    C   Leave The System Processes Alone, Things Break If I Don't
0415    C
0416     
0417    C	  IF (ACCNAM(1:ACCNAM_L) .eq. 'SYSTEM') then
0418    C	    STOPABLE(CUR_PID) = .false.
0419    C	    GOTO 20
0420    C	   end if
0421     
0422    C
0423    C   I leave The Systems Staff Alone, Otherwise I Would Be Considered
0424    C   Anti-Social.
0425    C
0426     
0427    C	  IF (GRPNUM .le. SYSGRP) then
0428    C	    STOPABLE(CUR_PID) = .false.
0429    C	    GOTO 20
0430    C	   end if
0431     
0432    C
0433    C   Debuging to only look at SYSGRP Uic's
0434    C
0435     

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  13
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0436 C  D	  IF (GRPNUM .ne. SYSGRP) then
0437 C  D	    STOPABLE(CUR_PID) = .false.
0438 C  D	    GOTO 20
0439 C  D	   end if
0440     

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  14
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0441    C
0442    C   If He Has No Tty Associated, He Is A Batch Job, Or An Acp
0443    C   Or Something Like That. If He Is A Batch Job During Primetime
0444    C   It Is Likely That He Is Not Running Enough To Notice. But
0445    C   If He a Subprocess Find His Parent terminal and send a message
0446    C   to him.
0447    C
0448 C  D901	FORMAT(' Working With Owner PID ',Z8)
0449     
0450    	  NO_WARNING = .FALSE.
0451    	  IF (TTYNUM_L .eq. 0) then
0452    	    DO WHILE (OWNER .ne. 0)
0453    	      SS_STATUS = SYS$GETJPI(%val(EFN),%ref(Owner),,
0454         +						%ref(JPIBUF2),,,)
0455 C  D	      TYPE *,'Type Return Status from SYS$GETJPI for Subprocess is ',
0456 C  D    +						SS_STATUS
0457 C  D	      TYPE 901,Owner
0458    	      IF (SS_STATUS) then
0459    	        SS_STATUS = SYS$WAITFR(%val(EFN))
0460    	       ELSE
0461    	        IF (SS_STATUS .ne. %loc(SS$_SUSPENDED)) then
0462    	          CALL LIB$STOP(%val(SS_STATUS))
0463    	         ELSE
0464    		  NO_WARNING = .TRUE.
0465    	         endif
0466    	       endif
0467                 end do
0468    	   IF ((TTYNUM_L .eq. 0) .and.
0469         +	       (.not. NO_WARNING)) GOTO 20
0470    	  else
0471    	   IF (SUBCOUNT .GT. 0) then
0472    	     WARNING(CUR_PID) = 0
0473    	     GOTO 10
0474    	    endif
0475    	   end if
0476     
0477    C
0478    C   Normal User, He Can Be Saved By Doing An I/O, Or Using 50ms Of Cpu
0479    C   If He Has Some Subprocess' Running Then He May Be Waiting
0480    C   So Don't Blow Him Away
0481    C
0482     
0483    	  IF ((BUFIOC(CUR_PID) .lt. NEWIOC) .or.
0484         +	      (CPUTIM(CUR_PID)+CPU_50MS .le. NEWCPU)) then
0485    	    WARNING(CUR_PID) = 0
0486    	    GOTO 10
0487    	   endif

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  15
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0488    C
0489    C   We Have Them Now, Check To See if We Can Start Sending Messages Yet
0490    C   to User and/or Central Operator
0491    C
0492     
0493 C  D	  TYPE *,'Number of Warning ',WARNING(CUR_PID)
0494    	  WARNING(CUR_PID) = WARNING(CUR_PID) + 1
0495     
0496    	  IF (WARNING(CUR_PID) .ge. START_MESSAGE) then
0497    	    MESSAGE = ' '
0498 C  D	    TYPE *,'Warn User ',USRNAM(1:USRNAM_L)
0499     
0500    C
0501    C   Determine If We Are Going to Make Them History for the Message
0502    C   Get Time of Day and Assemble The Message
0503    C
0504    	    LOGOFF_MSG = LOGOFF_DEF
0505    	    IF (WARNING(CUR_PID) .ne. STOP_MESSAGE) LOGOFF_MSG = ' '
0506    	    CALL TIME(TIMBF)
0507    	    Usrnam_l = LIB$MATCHC(' ',usrnam) - 1
0508    	    If (No_Warning) then
0509    	      TTYNUM   = UNKNOWN_TERM
0510    	      TTYNUM_L = len(UNKNOWN_TERM)
0511    	     end if
0512    	    SS_STATUS = SYS$FAO(FAO_IN_STR, MESSAGE_LEN, MESSAGE,
0513         +				TIMBF,
0514         +				USRNAM(1:usrnam_l),
0515         +				TTYNUM(1:ttynum_l),
0516         +				%val(TIME_MINUTES*WARNING(CUR_PID)),
0517         +				LOGOFF_MSG)
0518    	    IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))
0519 C  D	    TYPE *,'STATUS RETURN FROM FAO IS ',SS_STATUS
0520 C  D	    TYPE *,'IDLE TIME ',TIME_MINUTES*WARNING(CUR_PID)
0521    C	    SS_STATUS = SYS$SNDOPR(OPER_MESS(1:Message_len+10),)
0522    C	    IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))
0523    	    IF (.not. NO_WARNING) then
0524    	      SS_STATUS = SYS$BRDCST(HEADER_MSG,TTYNUM)
0525    	      IF ((.not. SS_STATUS) .and. 
0526         +		  (SS_STATUS .ne. %loc(SS$_DEVOFFLINE))) 
0527         +			CALL LIB$STOP(%val(SS_STATUS))
0528    	      SS_STATUS = SYS$BRDCST(OPER_MESS(9:Message_len+10),TTYNUM)
0529    	      IF ((.not. SS_STATUS) .and. 
0530         +		  (SS_STATUS .ne. %loc(SS$_DEVOFFLINE)))
0531         +			CALL LIB$STOP(%val(SS_STATUS))
0532    	     endif
0533    	   endif

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  16
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

0534    C
0535    C   Can We Delete Process, Check
0536    C
0537     
0538    	  IF (WARNING(CUR_PID) .eq. STOP_MESSAGE) then
0539 C  D	    TYPE *,'Deleting User ',USRNAM(1:USRNAM_L)
0540    	    SS_STATUS = SYS$SNDOPR(OPER_MESS(1:Message_len+10),)
0541    	    IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))
0542    	    IF (NO_WARNING) then
0543    	      SS_STATUS = SYS$RESUME(%ref(OWNER),)
0544    	      IF ((SS_STATUS .ne. %loc(SS$_NORMAL)) .and.
0545         +		   SS_STATUS .ne. %loc(SS$_NONEXPR)) 
0546         +		CALL LIB$STOP(%val(SS_STATUS))
0547    	     endif
0548    	    SS_STATUS = SYS$DELPRC(%ref(PID),)
0549    	    IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))
0550    	   endif
0551     
0552    C
0553    C   Go Get Another Process, Also Assign the CPUTIM and BUFIOC
0554    C
0555     
0556    10	  CONTINUE
0557    	  CPUTIM(CUR_PID)=NEWCPU
0558    	  BUFIOC(CUR_PID)=NEWIOC
0559    20	  CONTINUE
0560    	END DO
0561    C
0562    C   Set Up a Scheduled Wake Up to Occur
0563    C
0564    	SS_STATUS = SYS$SCHDWK(,,BINTIM,)
0565    	IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))
0566    C
0567    C  Dont Waste Memory While Waiting
0568    C
0569    	SS_STATUS = SYS$PURGWS(%ref(RANGE))
0570    	IF (.not. SS_STATUS) CALL LIB$STOP(%val(SS_STATUS))
0571    C
0572    C  Hibernate Till the Scheduled Wake-up
0573    C
0574     
0575 C  D	TYPE *,'Going To Hiberate'
0576    	SS_STATUS = SYS$HIBER()
0577 C  D	TYPE *,'WATCH DOG Awake And Feeling Refreshed'
0578     	GOTO 1
0579    	end						! Call It a Day

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  17
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

PROGRAM SECTIONS

    Name				 Bytes   Attributes

  0 $CODE                                 1475   PIC CON REL LCL   SHR   EXE   RD NOWRT LONG
  1 $PDATA                                 184   PIC CON REL LCL   SHR NOEXE   RD NOWRT LONG
  2 $LOCAL                                4648   PIC CON REL LCL NOSHR NOEXE   RD   WRT LONG

    Total Space Allocated                 6307


ENTRY POINTS

    Address  Type  Name                                        References

  0-00000000       WATCH_DOG                                       1     


VARIABLES

    Address  Type  Name                            Attributes  References

  2-000000BF  I*4  ACCADDR                              EQUIV    113       199       254=    
  2-000000C3  I*4  ACCLEN                               EQUIV    113       199       255=    
  2-0000100D  CHAR ACCNAM                                         98       254     
  2-00001090  I*4  ACCNAM_L                                      113       255     
  2-00001048  CHAR ASCTIM                                         98       304A      311A      314A    

  2-0000009B  I*4  BIOADDR                              EQUIV    113       199       242=    
  2-0000009F  I*4  BIOLEN                               EQUIV    113       199       243=    
  2-00000093  I*4  CPULEN                               EQUIV    113       199       239=    
  2-0000008F  I*4  CPUTADDR                             EQUIV    113       199       238=    
  2-00001060  I*4  CUR_PID                                       113       384=      391       393       394       395     
							         404       472       483(2)    485       494(2)    496     
							         505       512       538       557       558     

  2-000000D7  I*4  GRPADDR                              EQUIV    113       199       262=    
  2-000000DB  I*4  GRPLEN                               EQUIV    113       199       263=    
  2-00001084  I*4  GRPNUM                                        113       262     
  2-00001030  CHAR LOGOFF_MSG                                     98       504=      505=      512A    
  2-0000000E  CHAR MESSAGE                              EQUIV     98       199       329=      351=      497=      512A    

  2-00001070  I*4  MESSAGE_LEN                                   113       512A      528       540     
  2-00000005  I*4  MS_TARGET                            EQUIV    113       199       297=    
  2-00000004  L*1  MS_TYPE                              EQUIV     92       199       296=    
  2-00001078  I*4  NEWCPU                                        113       238       483       557     
  2-0000107C  I*4  NEWIOC                                        113       242       483       558     

  2-0000100C  L*1  NO_WARNING                                     92       450=      464=      468       508       523     
							         542     
  2-00000004  CHAR OPER_MESS                            EQUIV     98       199(2)    298=      330A      352A      528A    
							         540A    
  2-00001074  I*4  OWNER                                         113       270       286       452       453A      543A    
  2-000000EF  I*4  OWNERADDR                            EQUIV    113       199       270=    
  2-00000073  I*4  OWNERADDR2                           EQUIV    113       199       286=    

  2-000000F3  I*4  OWNERLEN                             EQUIV    113       199       271=    

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  18
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

  2-00000077  I*4  OWNERLEN2                            EQUIV    113       199       287=    
  2-00000000  I*4  PID                                  EQUIV    113       199       234       548A    
  2-00000083  I*4  PIDADDR                              EQUIV    113       199       234=    
  2-00000087  I*4  PIDLEN                               EQUIV    113       199       235=    

  2-000000E3  I*4  PRCCADDR                             EQUIV    113       199       266=    
  2-000000E7  I*4  PRCCLEN                              EQUIV    113       199       267=    
  2-0000105C  I*4  SEEDPID                                       113       363=      366A    
  2-00001064  I*4  SS_STATUS                                     113       304=      305(2)    314=      317(2)    323=    
							         324(2)    330=      332(2)    352=      354(2)    364=    
							         365       366=      369       370=      372(2)    374     
							         453=      458       459=      461       462       512=    
							         518(2)    524=      525(3)    528=      529(3)    540=    
							         541(2)    543=      544(3)    548=      549(2)    564=    
							         565(2)    569=      570(2)    576=    
  2-00001068  I*4  START_IDX                                     113       311=      314(2)  

  2-00001080  I*4  STATE                                         113       246       410(2)  
  2-000000A7  I*4  STATEADDR                            EQUIV    113       199       246=    
  2-000000AB  I*4  STATELEN                             EQUIV    113       199       247=    
  2-00001088  I*4  SUBCOUNT                                      113       266       471     
  2-000000CB  I*4  TERMADDR                             EQUIV    113       199       258=    

  2-00000067  I*4  TERMADDR2                            EQUIV    113       199       282=    
  2-000000CF  I*4  TERMLEN                              EQUIV    113       199       259=    
  2-0000006B  I*4  TERMLEN2                             EQUIV    113       199       283=    
  2-00001015  CHAR TIMBF                                          98       506A      512A    
  2-0000106C  I*4  TIME_MINUTES                                  113       314A      512     

  2-00001058  I*4  TIME_STAMP                                    113       339=      346(2)=   350       355=    
  2-0000101D  CHAR TTYNUM                                         98       258       282       509=      512A      524A    
							         528A    
  2-00001094  I*4  TTYNUM_L                                      113       259       283       451       468       510=    
							         512     
  2-000000B3  I*4  USERADDR                             EQUIV    113       199       250=    
  2-000000B7  I*4  USERLEN                              EQUIV    113       199       251=    

  2-00001024  CHAR USRNAM                                         98       250       507A      512A    
  2-0000108C  I*4  USRNAM_L                                      113       251       507=      512     


ARRAYS

    Address  Type  Name          Attributes        Bytes  Dimensions       References

  2-000000FC  I*4  BINTIM                             8  (2)               113       304A      564A    
  2-0000050C  I*4  BUFIOC                          1024  (256)             113       483       558=    
  2-0000010C  I*4  CPUTIM                          1024  (256)             113       483       557=    
  2-0000007F  I*2  JPIBUF             EQUIV         124  (62)              108       199(20)   232=      233=      236=    
									   237=      240=      241=      244=      245=    
									   248=      249=      252=      253=      256=    
									   257=      260=      261=      264=      265=    
									   268=      269=      272=      273=      366A    
  2-00000063  I*2  JPIBUF2            EQUIV          28  (14)              108       199(4)    280=      281=      284=    
									   285=      288=      289=      453A    

  2-00000004  L*1  OPER_MSG_BUF       EQUIV           8  (8)                92       199(3)  

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  19
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

  2-00000104  I*4  RANGE                              8  (2)               113D      569A    
  2-00000D0C  I*2  SEQ                              512  (256)             108       391       393=    
  2-00000000  I*2  SEQ_NUMBER         EQUIV           4  (2)               108       199       384       391       393     
  2-00000F0C  L*1  STOPABLE                         256  (256)              92       395=      404     

  2-0000090C  I*4  WARNING                         1024  (256)             113       394=      472=      485=      494(2)= 
									   496       505       512       538     


PARAMETER CONSTANTS

  Type  Name                                                   References

   CHAR BELL                                                      69(3)#   298(2)  
   I*2  CPU_50MS                                                  69#      483     
   I*2  EFN                                                       69#      366       370       453       459     
   CHAR FAO_IN_STR                                                69#      512     
   CHAR HEADER_MSG                                                69#      524     

   CHAR INIT_MSG                                                  69#      329     
   I*2  JPI_WILDCARD                                              69#      363     
   CHAR LOGOFF_DEF                                                69#      504     
   I*2  MAXUSER                                                   69#       92       108       113(3)  
   CHAR PROCESS_NAME                                              69#      323     

   I*2  SEND_STAMP                                                69#      339       350     
   CHAR STAMP_MSG                                                 69#      351     
   I*2  START_MESSAGE                                             69#      496     
   I*2  STOP_MESSAGE                                              69#      505       538     
   I*2  SYSGRP                                                    69#    

   CHAR UNKNOWN_TERM                                              69#      509       510     


LABELS

    Address   Label                                            References

  0-00000230  1                                                  345#      578     
  0-00000564  10                                                 396       404       410       473       486       556#    
  0-00000576  20                                                 376       468       559#    


FUNCTIONS AND SUBROUTINES REFERENCED

  Type  Name                                                   References

        FOR$TIME_T_DS                                            506     
        JPI$C_LISTEND                                            175       272       273       288       289     
        JPI$_ACCOUNT                                             175       253     
        JPI$_BUFIO                                               175       241     
        JPI$_CPUTIM                                              175       237     

        JPI$_GRP                                                 175       261     
        JPI$_OWNER                                               175       269       285     
        JPI$_PID                                                 175       233     
        JPI$_PRCCNT                                              175       265     

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  20
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

        JPI$_STATE                                               175       245     

        JPI$_TERMINAL                                            175       257       281     
        JPI$_USERNAME                                            175       249     
   I*4  LIB$MATCHC                                               113       311       507     
        LIB$STOP                                                 305       317       324       332       354       374     
							         462       518       525       529       541       544     
							         549       565       570     
        OPC$M_NM_CENTRL                                          175       297     

        OPC$_RQ_RQST                                             175       296     
   I*4  OTS$CVT_TI_L                                             113       314     
        SCH$C_HIB                                                175       410     
        SCH$C_HIBO                                               175       410     
        SS$_DEVOFFLINE                                           175       525       529     

        SS$_NOMOREPROC                                           175       365       372     
        SS$_NONEXPR                                              175       544     
        SS$_NORMAL                                               175       544     
        SS$_SUSPENDED                                            175       372       461     
   I*4  SYS$BINTIM                                               113       304     

   I*4  SYS$BRDCST                                               113       524       528     
   I*4  SYS$DELPRC                                               113       548     
   I*4  SYS$FAO                                                  113       512     
   I*4  SYS$GETJPI                                               113       366       453     
   I*4  SYS$HIBER                                                113       576     

   I*4  SYS$PURGWS                                               113       569     
   I*4  SYS$RESUME                                               113       543     
   I*4  SYS$SCHDWK                                               113       564     
   I*4  SYS$SETPRN                                               113       323     
   I*4  SYS$SNDOPR                                               113       330       352       540     

   I*4  SYS$WAITFR                                               113       370       459     


  +----------------------------------------------+
  |           KEY TO REFERENCE FLAGS             |
  |   =   - Value Modified                       |
  |   #   - Defining Reference                   |
  |   A   - Actual Argument, possibly modified   |
  |   D   - Data Initialization                  |
  |  (n)  - Number of occurrences on line        |
  +----------------------------------------------+



COMMAND QUALIFIERS

  FORTRAN /LIST/CROSS/CONTIN=99 WATCHDOG.FOR

  /CHECK=(NOBOUNDS,OVERFLOW,NOUNDERFLOW)
  /DEBUG=(NOSYMBOLS,TRACEBACK)
  /STANDARD=(NOSYNTAX,NOSOURCE_FORM)
  /SHOW=(NOPREPROCESSOR,NOINCLUDE,MAP)
  /F77  /NOG_FLOATING  /I4  /OPTIMIZE  /WARNINGS  /NOD_LINES  /CROSS_REFERENCE  /NOMACHINE_CODE  /CONTINUATIONS=99

WATCH_DOG                      					26-Apr-1985 10:17:32	VAX-11 FORTRAN V3.0-2               Page  21
								26-Apr-1985 10:16:58	WATCHDOG.FOR;120                            

COMPILATION STATISTICS

  Run Time:           6.66 seconds
  Elapsed Time:       10.55 seconds
  Page Faults:        283
  Dynamic Memory:     203 pages
</pre></body></html>