You can use the COBOL pointer feature to access system areas in an IBM mainframe environment. You also may be able to do that in other environments.
Your best bet is to find a UNIX forum and ask how to chain through the UNIX system data, then determine how to do that in COBOL using pointers. At that point you might be able to get some help here.
If you're lucky there may be somebody here that has done something similar and can help.
I don't know about MF Cobol, but RM/Cobol on Unix provides for executing a system command via a CALL "SYSTEM" USING CMD-STRING feature. You can then execute an arbitrary command by building it the CMD-STRING.
If you have a similar feature available, you should be able to run something like:
ps -u $(LOGNAME) > my-processes.txt
You will then be able to turn around and read "my-processes.txt" as a simple sequential text file and search for the process you are looking for. If you put the above command string in a uniquely named script, you should be able to find that script name in the command text portion of the ps output, and use the corresponding parent process id (PPID) to identify your process id.
I've not actually done this. Fortunately, RM/Cobol also provides a callable routine "C$GetSysInfo" that returns, among other things, the specific process id. But I am sure that you should be able to get something like this to work.
"Code what you mean,
and mean what you code!
But by all means post your code!"
When your running program does a 'Call "SYSTEM"' it will give birth the a child process with it's own PID.(easy right? Why do women make such a fuzz about that).
As long as you realize that and go and look for the PID of the parent istead of it's own PID then it will be OK.
If your program is executed by a script it is more easy to "SET" an environment variable with the value of the PID. This can be retrieved using DISPLAY/ACCEPT UPON/FROM ENVIRONMENT NAME/VALUE.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.