Trailing-Edge
-
PDP-10 Archives
-
integ_tools_tops20_v7_30-apr-86_dumper
-
tools/com/fork.com
There are 3 other files named fork.com in the archive. Click here to see a list.
$ save_verify = 'f$verify(command$debug)
$!
$! FORK.COM
$! Emulate the TOPS-20 FORK command
$! GMU 22-Aug-83 22:11 Version 2.03
$!
$! Command syntax is:
$!
$! $ FORK name
$!
$! "name" is the name of a subprocess in the current process structure.
$! It may be abbreviated to the number of characters that make it unique.
$!
$ on control_y then goto cleanup
$ priv_list = f$setprv("NOWORLD,NOGROUP") ! Restrict to current job
$!
START:
$ if p1 .eqs. "" .or. -
p1 .eqs. "?" then goto fork_help ! See if help wanted
$ p1_length = f$length(p1) ! Get length of process name
$ context = "" ! Cycle through process names
$!
$! Loop over all processes in this job getting their names. If the name
$! matches the process name given as the argument to the command, attach
$! to it.
$!
FORK_LOOP:
$ pid = f$pid(context) ! Get next pid in this process
$ if pid .eqs. "" then goto no_fork ! F$pid returns null when done
$ proc_name = f$getjpi(pid,"prcnam") ! Get process name of this pid
$ upper_proc_name := 'proc_name' ! Copy to force upper case
$ if p1 .eqs. f$extract(0,p1_length,"''upper_proc_name'") then -
$ goto found_fork ! If name matches, attach to it
$ goto fork_loop ! Try next process name
$!
$! Here when we found a process that we want to attach.
$!
FOUND_FORK:
$ priv_list = f$setprv(priv_list) ! Restore privs
$ attach "''proc_name'" ! attach to the process
$ goto done ! Go finish up
$!
$! Here if the specified fork wasn't found
$!
NO_FORK:
$ write SYS$OUTPUT "%E, Process not found"
$ Goto cleanup
$!
$!
$! Here when done to clean up things
$!
$!
CLEANUP:
$ priv_list = f$setprv(priv_list) ! Restore privs
DONE:
$ save_verify = 'f$verify(save_verify)' ! Restore verify
$ exit
$!
$! Here to help the user
$!
FORK_HELP:
$ write sys$output "$ Fork (is) ? Fork name, one of the following:"
$ context = ""
FORK_HELP_LOOP_1:
$ help_line = ""
$ help_line_count = 0
FORK_HELP_LOOP_2:
$ pid = f$pid(context) ! Get next pid in this process
$ if pid .eqs. "" then goto fork_help_end ! F$pid returns null when done
$ help_line = help_line + " ''f$getjpi(pid,"prcnam")' "
$ help_line_count = help_line_count + 1
$ if help_line_count .lt. 4 then goto fork_help_loop_2
$ write sys$output "''help_line'"
$ goto fork_help_loop_1
$!
FORK_HELP_END:
$ if help_line_count .ne. 0 then -
$ write sys$output "''help_line'"
$ inquire/nopunctuation p1 "$ Fork (is) " ! Get fork name
$ goto start ! Try again