Sometimes it is necessary to make the process-ID (PID) available to the program. This article describes several ways to do so.
Problem:
There are several ways to read the process-ID. Some of them are provided by Micro Focus within the Runtime-System, but they do not work in all versions.
Resolution:
Version 6 and before:
Process-id cannot be read.
Versions 7 and 8:
Use the C$GETPID library routine. This routine is documented In the ACUCOBOL-GT Appendices manual, Appendix I.
Summary:
Version 7 can only read on a Unix-RT, Version 8 from Unix or Windows.
Other workarounds to read the PID:
set environment "dll-convention" to "1"
call "kernel32.dll"
call "GetCurrentProcessId"
giving ProcessId
cancel "kernel32.dll"
with definition of ProcessId : s9(9) comp-5 [Windows says only 9(9) comp-5]
and recommanded compile options : -Dl4 -Dw32
set environment ... can be replaced by the environmment variable DLL-CONVENTION 1
Another option is a program that you can download from the web called "Pulist.exe". If you run Pulist from your command prompt you can get the PID of the processes running in your Windows machine. If you want to narrow down your search you can download the grep.exe program for Windows as well. Then you can run:
pulist | grep wrun32.exe, and will give you the runtime's PID.
Then you can send this output to a sequential file and read it from a COBOL program.



