Get PID of own progress session in UNIX

chrisw669

New Member
Is it possible for a progress session to determine the PID (process id) of itself? I'm trying to use named pipes for multiple progress sessions and want to name the pipe(s) according to the PID of the progress session (batch mode) that will use it.
 
A quick way it to shell out the os. But I should this code is not portable across platforms.

Code:
DEFINE VARIABLE chPID AS CHARACTER   NO-UNDO.

INPUT THROUGH 'echo $$' NO-ECHO.
IMPORT UNFORMATTED chPID.
INPUT CLOSE.

MESSAGE chPID.

BWT, It is possible to get the PID from the VST tables. I can't remember how, but it can be done.
 
something like that ?

&IF OPSYS="WIN32" &THEN
PROCEDURE GetCurrentProcessId EXTERNAL "kernel32.dll":
DEFINE RETURN PARAMETER pl_pid AS LONG NO-UNDO.
END PROCEDURE.
&ENDIF

DEFINE VARIABLE ppid AS CHARACTER NO-UNDO.
&IF OPSYS="UNIX" &THEN
INPUT THROUGH "echo $PPID".
DO ON ENDKEY UNDO, LEAVE:
IMPORT ppid.
END.
INPUT CLOSE.
&ELSE
DEFINE VARIABLE i_ppid AS INTEGER NO-UNDO.
RUN GetCurrentProcessId(OUTPUT i_ppid) NO-ERROR.
ppid = STRING(i_ppid) NO-ERROR.
&ENDIF
 
Back
Top