- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: GETJPI & image name of MASTER_PID
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2007 10:32 AM
06-22-2007 10:32 AM
I've finally figured out how to get LIB$GETJPI working with COBOL to get process ID, process name, image name, etc. but I need to call a cobol app from within several other Cobol apps and can't determine how to get the Image Name of the Master Process (the name of the calling application). I've tried the test program below. The MASTER_PID comes back correctly but nothing is returned for the IMAGNAME in the second call. I'm sure the solution is very simple but being to calling these routines from within Cobol, the solution eludes me.
Thanks for any thoughts or solutions you may have.
IDENTIFICATION DIVISION.
PROGRAM-ID. GET_JPI.
*
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 JPI$_MASTER_PID PIC S9(9) COMP VALUE EXTERNAL JPI$_MASTER_PID.
01 JPI$_IMAGNAME PIC S9(9) COMP VALUE EXTERNAL JPI$_IMAGNAME.
01 STAT PIC S9(9) COMP.
01 MPID PIC X(09).
01 IMAGNAME PIC X(80).
************************************************************
PROCEDURE DIVISION.
BEGIN.
CALL 'LIB$GETJPI' USING BY REFERENCE JPI$_MASTER_PID
OMITTED,
OMITTED,
OMITTED,
BY DESCRIPTOR MPID
GIVING STAT.
DISPLAY "MASTER_PID RETURNED BY LIB$GETJPI: " MPID
DISPLAY "".
DISPLAY "Master_PID: " MPID.
CALL 'LIB$GETJPI' USING BY REFERENCE JPI$_IMAGNAME
BY REFERENCE JPI$_MASTER_PID,
OMITTED,
OMITTED,
BY DESCRIPTOR IMAGNAME
GIVING STAT.
DISPLAY "MASTER_IMGNAM RETURNED BY LIB$GETJPI: " IMAGNAME
STOP RUN.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2007 11:02 AM
06-22-2007 11:02 AM
SolutionEasy problem...
You need to pass the returned value of the masterpid from the first call as second argument to the second call. That should be the binary value, not the text value you currently obtain.
See program below with added "MPID-VALUE" variable. I also replaced IMAGNAME by PRCNAM... Same principle, but easier to test.
Run example:
$ run test
MASTER_PID RETURNED BY LIB$GETJPI: 00137229
My name RETURNED BY LIB$GETJPI: HEIN_1
Master RETURNED BY LIB$GETJPI: HEINEKEN
Program below.
Cheers,
Hein.
IDENTIFICATION DIVISION.
PROGRAM-ID. GET_JPI.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 JPI$_MASTER_PID PIC S9(9) COMP VALUE EXTERNAL JPI$_MASTER_PID.
01 JPI$_PRCNAM PIC S9(9) COMP VALUE EXTERNAL JPI$_PRCNAM.
01 STAT PIC S9(9) COMP.
01 MPID PIC X(09).
01 MPID-VALUE PIC S9(9) COMP.
01 IMAGNAME PIC X(80).
************************************************************
PROCEDURE DIVISION.
BEGIN.
CALL 'LIB$GETJPI' USING BY REFERENCE JPI$_MASTER_PID
OMITTED,
OMITTED,
MPID-VALUE,
BY DESCRIPTOR MPID
GIVING STAT.
DISPLAY "MASTER_PID RETURNED BY LIB$GETJPI: " MPID
CALL 'LIB$GETJPI' USING BY REFERENCE JPI$_PRCNAM
OMITTED,
OMITTED,
OMITTED,
BY DESCRIPTOR IMAGNAME
GIVING STAT.
DISPLAY "My name RETURNED BY LIB$GETJPI: " IMAGNAME
CALL 'LIB$GETJPI' USING BY REFERENCE JPI$_PRCNAM
MPID-VALUE,
OMITTED,
OMITTED,
BY DESCRIPTOR IMAGNAME
GIVING STAT.
DISPLAY "Master RETURNED BY LIB$GETJPI: " IMAGNAME
STOP RUN.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2007 06:51 AM
06-23-2007 06:51 AM
Re: GETJPI & image name of MASTER_PID
It's certainly possible (and encouraged) to build up a library of calls from COBOL, and there are many useful examples in the support databases that can be of assistance toward that goal. COBOL itself is arguably one of the more difficult languages to call OpenVMS system functions from, particularly those functions involving pointers and itemlists. There are some links into the support databases at the top level of the ITRC site. http://www.itrc.hp.com. Once you master these argument-passing mechanisms, the remaining calls -- well, with the exception of one SMG call, SMG$SELECT_FROM_MENU :-) -- are easier.
Should you continue to pursue direct calls, I would encourage acquiring (or creating for yourself) examples of calling sys$getjpi[w], sys$getsyi[w], sys$getdvi[w] or other similar calls -- these are the most difficult calls from COBOL, but they are also salient examples -- microcosms -- of the classic OpenVMS programming interfaces.
As for what you are working on here with the job tree and the image names, dependencies on such things as the parent process and the calling image name tend to be non-modular; some details on why you're considering this approach might be in order, and whether or not there are alternative approaches.
If you're looking for tracebacks on failures and for logging and reporting problems (or for logging run-times and performance), there are approaches toward that end.
If you're looking to conditionalize processing based on the calling sequence of processes in the job tree, there are other approaches I'd pick (long) before I looked at the images and the job tree and processes.
Some background, please? What problem(s) might you be addressing here?
Stephen Hoffman
HoffmanLabs LLC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2007 02:42 AM
06-25-2007 02:42 AM
Re: GETJPI & image name of MASTER_PID
Thanks for the assistance, I now have a working application. Out existing applications use a "banner" page when ever an application is run to give a brief description of what the application does and allow the user to modify report settings before actually running the report. This is done by calling a generic library module that determines what program it is being called from and then displaying the appropriate docs and settings. I want to enhance this banner application but we do not have the source code for this particular one, so I am writing my own version from scratch with the enhancements I want. The final sticking point was determining what image was being run by the master process without having to resort to passing variables or setting a logical. The original banner program does neither of these so I wanted to keep them functionally the same. If there is a better alternative, I'm all ears.
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2007 03:10 AM
06-25-2007 03:10 AM
Re: GETJPI & image name of MASTER_PID
Yeah, sounds like you are SPAWNING the help application.
The better alternative is to put that code in a share-able library and use LIB$FIND_IMAGE_SYMBOL to activate it if and when needed.
In doing so the help will run in full process context and you can pass anything you darn well please. It wil also be cheaper on the system, notably if frequently re-activated.
It's the VMS way of doing things.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2007 04:36 AM
06-25-2007 04:36 AM
Re: GETJPI & image name of MASTER_PID
Thanks again for for sharing your expertise.
I can tell I will be using this venue more often and should have been using it more in the past.