Re: Which processes use shared image



Eirrub wrote:
Hello,

Does someone know how you can find the processes which are making use
of a specific shared image?

Thanks,

Frank Burrie.

The usual reason for wanting this information is that you want to
de-install a shared image that someone has open, and because it's
installed /SHARE, SHOW DEV/FILES does not provide you with the
information to locate the process.

Unfortunately, as far as I know there's no "easy" way to find processes
that have channels open in this situation.

Here's a DCL command procedure that brute forces the solution using
SDA's SHOW PROCESS/CHANNEL command:

$! See bottom of file for comments.
$ set on
$ on warning then goto error
$ on control_y then goto error
$ say := write sys$output
$ ask := read/error=error/end_of_file=error sys$command -
command/prompt=
$ do_header = 1
$ required_privs = "WORLD, CMKRNL"
$ old_privs = f$setprv (required_privs)
$ if .not. f$privilege (required_privs)
$ then
$ say "Required privileges: " + required_privs
$ goto exit
$ endif
$ask_p1:
$ image = f$edit (p1, "uncomment, collapse")
$ if image .eqs. ""
$ then
$ ask "Image to search for? "
$ p1 = command
$ goto ask_p1
$ endif
$ if f$search (image) .eqs. ""
$ then
$ say "Can't find image: " + image
$ p1 = ""
$ goto ask_p1
$ endif
$ image = "]" + f$parse (image,,,"name") + -
f$parse (image,,,"type") + ";"
$
$ context = ""
$ temp1 = "sys$scratch:" + f$unique() + ".tmp"
$ temp2 = "sys$scratch:" + f$unique() + ".tmp"
$loop:
$ pid = f$pid (context)
$ if pid .eqs. ""
$ then
$ goto end_loop
$ endif
$ open/write out 'temp1'
$ write out "$ define/user sys$output nl:"
$ write out "$ define/user sys$error n:"
$ write out "$ analyze/system"
$ write out "$ deck"
$ write out "set output " + temp2
$ write out "show process/channel/index=" + pid
$ write out "exit"
$ write out "$ eod"
$ write out "$ exit"
$ close out
$ @'temp1'
$ delete/nolog 'temp1';*
$ define/user sys$output nl:
$ define/user sys$error nl:
$ search 'temp2' "''image'"
$ if f$integer ($status) .eq. 1
$ then
$ if do_header
$ then
$ do_header = 0
$ say "PID Process"
$ endif
$ say pid + " " + f$getjpi (pid, "prcnam")
$ endif
$ delete/nolog 'temp2';*
$ goto loop
$end_loop:
$ goto exit
$error:
$ set noon
$exit:
$ if f$trnlnm ("out") .nes. ""
$ then
$ close out
$ endif
$ if f$type (temp1) .nes. ""
$ then
$ if f$search (temp1) .nes. ""
$ then
$ delete/nolog 'temp1';*
$ endif
$ endif
$ if f$type (temp2) .nes. ""
$ then
$ if f$search (temp2) .nes. ""
$ then
$ delete/nolog 'temp2';*
$ endif
$ endif
$ old_privs = f$setprv (old_privs)
$ exit
$!++
$!
$! DESCRIPTION
$!
$! This command procedure, given the name of an image file
$! (or any file for that matter) uses SDA's SHOW PROCESS/CHANNEL
$! command to locate processes that have an open channel to
$! files of that name. Note only the file name and type are
$! matched, but this will usually be quite enough to locate the
$! process you are looking for (and that way I don't have to get
$! into messy file parsing and searching).
$!
$! AUTHOR
$!
$! James F. Duff
$!
$! DATE
$!
$! 23-Jun-2009
$!
$! MODIFICATIONS
$!
$! X01-00 Jim Duff 23-Jun-2009
$! Original version of module.
$!
$!--


HTH,
Jim.
--
www.eight-cubed.com
.



Relevant Pages

  • Re: loop never exits on ESC
    ... I just added following command in my code ... It functions much like the ON KEY LABEL. ... >> ENDIF ... >> EXIT ...
    (microsoft.public.fox.programmer.exchange)
  • Re: what is the difference?
    ... > Could somebody tell me what the difference between these 2 scripts are? ... > exit 1 ... define $status to the the value of the last command executed. ...
    (comp.unix.shell)
  • Re: [PATCH][RFC 2/3/2/5] SCST pass-through dev handlers
    ... * modify it under the terms of the GNU General Public License ... without even the implied warranty of ... This does the parsing of the command ...
    (Linux-Kernel)
  • kbuild: Separate output directory - core patch
    ... # This patch format is intended for GNU patch command version 2.5 or higher. ... # Enable the possibility to build a kernel in a separate output ... +# or the modules are listed in "prepare-all". ...
    (Linux-Kernel)
  • [PATCH 6/19]: SCST internal library functions
    ... This patch contains SCST internal library functions. ... * Allocates, if necessary, sense buffer for command. ...
    (Linux-Kernel)