Google
 

Trailing-Edge - PDP-10 Archives - LCG_Integration_Tools_Clearinghouse_T20_v7_30Apr86 - tools/com/reset.com
There are 3 other files named reset.com in the archive. Click here to see a list.
$ save_verify = 'f$verify(command$debug)'
$!
$! RESET.COM
$! Emulate the TOPS-20 RESET command
$! GMU	19-Aug-83 09:35	Version 2.02
$!
$! Command syntax is:
$!
$!	$ RESET				;For current process
$!	$ RESET .			;For current process
$!	$ RESET *			;For all processes
$!	$ RESET name			;For specific process
$!
$! If a specific process name is given, only enough must be specified
$! to make it unique.
$!
$! Find the PID and name of the top-level owner process
$!
$ owner_pid = f$pid(0)			! Get pid of current process
$!
OWNER_PID_LOOP:
$ pid = f$getjpi(owner_pid,"owner")	! Get pid of owner
$ if pid .eqs. "" then goto owner_pid_end ! pid is null if no owner
$ owner_pid = pid			! Make that the new owner
$ goto owner_pid_loop			! Try again
$!
OWNER_PID_END:
$ on control_y then goto done
$ priv_list = f$setprv("NOWORLD,NOGROUP") ! Restrict to current job
$!
START:
$ if p1 .eqs. "?" then goto reset_help	! See if user wants help
$ if p1 .eqs. "" .or. -			! RESET <CR> or
     p1 .eqs. "." then goto done	! RESET . is a no-op
$!
$! Loop over all processes in this job getting their names.  If the name
$! matches the process name given as the argument to the command, or if
$! the argument was a "*", stop the process.
$!
$ p1_length = f$length(p1)		! Get length of process name
$ context = ""				! Cycle through process names
$!
RESET_LOOP:
$ pid = f$pid(context)			! Get next pid in this process
$ if pid .eqs. "" then goto done	! F$pid returns null when done
$ if owner_pid .eqs. pid then -		! If this is the top process,
$	goto reset_loop			!   don't kill is (it's a logout)
$ proc_name = f$getjpi(pid,"prcnam")	! Get process name
$ upper_proc_name := 'proc_name'	! Copy to force upper case
$ if p1 .eqs. "*" .or. -
     p1 .eqs. f$extract(0,p1_length,"''upper_proc_name'") then -
	goto kill_process		! If name matches, kill it
$ goto reset_loop			! Try next process name
$!
$! Here when we found a process that we want to kill.
$!
KILL_PROCESS:
$ stop "''proc_name'"			! Stop the process
$ goto reset_loop			! Try next name
$!
$! Here when done to clean up things
$!
DONE:
$ priv_list = f$setprv(priv_list)	! Restore privs
$ save_verify = 'f$verify(save_verify)'	! Restore verify
$ exit
$!
$!
$! Here to help the user
$!
RESET_HELP:
$ write sys$output "$ Reset (fork) ? Fork name, one of the following:"
$ context = ""
RESET_HELP_LOOP_1:
$ help_line = ""
$ help_line_count = 0
RESET_HELP_LOOP_2:
$ pid = f$pid(context)			! Get next pid in this process
$ if pid .eqs. "" then goto reset_help_end ! F$pid returns null when done
$ if pid .eqs. owner_pid then goto reset_help_loop_2
$ help_line = help_line + "	''f$getjpi(pid,"prcnam")'	"
$ help_line_count = help_line_count + 1
$ if help_line_count .lt. 4 then goto reset_help_loop_2
$ write sys$output "''help_line'"
$ goto reset_help_loop_1
$!
RESET_HELP_END:
$ if help_line_count .ne. 0 then -
$	write sys$output "''help_line'"
$ write sys$output "   or * for all forks"
$ write sys$output "   or . or CR for current fork"
$ inquire/nopunctuation p1 "$ Reset (fork) "
$ goto start