Hi All,
Does anyone know a way that I could start a process within a Progress ABL session and be able to obtain the PID? I'm running on a unix box.
Thanks,
Andre
Check _Connect table field _Connect-pid
Maxim,
The _connect table shows me the pid . However, If I have multiple sessions being started sequentially. How can I determine which pid is assigned to each session? I'm launching an mbpro session and is there an attribute of parameter that I can use to determine which pid is assigned towhich session.
Thanks,
Andre
we use code like:
FOR EACH _Connect NO-LOCK WHERE _Connect-Usr NE ?
AND
(_Connect-Type EQ "REMC" OR _Connect-Type EQ "SELF" or _Connect-Type EQ "0" )
BREAK BY _Connect-Usr:
IF _Connect-PID = ? THEN
NEXT.
IF _Connect-Type EQ "SELF" OR _Connect-Device NE "" THEN
ASSIGN cClientType = "4GL Client".
ELSE
ASSIGN cClientType = "SQL-92 Client".
FIND FIRST users WHERE users.sys-name = _Connect-Name NO-LOCK NO-ERROR.
IF AVAILABLE users THEN
DO:
user-name = users.Name.
rid-user = users.rid-user.
END.
ELSE
user-name = _Connect-Name.
CREATE work-users1.
ASSIGN
work-users1.logininfo = string (_Connect-time)
work-users1.tty-name = _Connect-Device
work-users1.user-name = user-name
work-users1.rid-user = rid-user
work-users1.pid = _Connect-PID
work-users1.id-proc = _Connect-Usr.
/* DISPLAY _Connect.*/
END.
Also you can use _MyConnection table to identify current session.
Maxim,
This is just what I needed. Thanks for your help..
Andre
You can use mpro -b with an & at the end instead of mbpro, as it is exactly the same command (cf. "Startup Command and Parameter Reference").
So, for example, if you were doing
mbpro -p MyProgram.p
Change it to
mpro -b -p MyProgram.p &
And now, thanks to Unix, you can access the PID of the most recent process sent to background by using the $! variable.
So if you wanted to save the PID using this method, do something like this:
PIDFILE=$HOME/myprogram.pid
mpro -b -p MyProgram.p &
echo $! > $PIDFILE
Another way:
procedure getpid external 'libc.so' cdecl.
define return parameter pid as long no-undo.
end.
def var p as int no-undo.
run getpid (output p).
Gus,
I must be having a bad day:
Could not open Dynamic Library: libc.so (8013)
DLL Error : /usr/lib64/libc.so: invalid ELF header (8014)
Could not load DLL procedure libc.so. (3258)
> cat $DLC/version
OpenEdge Release 10.2B as of Mon Dec 14 17:00:19 EST 2009
> uname -a
Linux newcastle 2.6.16.13-4-smp #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux
Any idea what I'm missing?
As it turns out... /usr/lib64/libc.so is a "ASCII C program text" file on my system. It looks like a script and refers to /lib64/libc.so.6 as the probable /libc.so.
Plugging that in fixes the problem.
Hmmmm.
I guess I did not test my example program in enough environments.
Isn't the field of data processing exciting and rewarding?
Do you also know how to do this on AIX? We've got a shell script right now that (by determining the parent pid of the os-command started command) but that's not very fast.
An API call would be faster, but there's no libc.so in /lib, only libc.a. (AIX 6.1)
Hello,
Yes, this can also be done on AIX.
The reference to libc.a is different it has to include shr.o. So the path can be "/usr/lib/libc.a(shr.o)" or "libc.a(shr.o)".
The file shr.o is a module that is included in libc.a (archive format).
procedure getpid external '/usr/lib/libc.a(shr.o)'cdecl.
define return parameter pid as long no-undo.
end.
def var p as int no-undo.
run getpid (output p).
message p.
I hope this helps.
Thanks for your reply. Sadly I get the following errors when executing this:
Could not open Dynamic Library: libc.a(shr.o) (8013)
DLL Error : Could not load module /usr/lib/libc.a(shr.o). (8014)
Could not load DLL procedure libc.a(shr.o). (3258)
Aha, found it, I need shr_64.o. Thank you very much indeed!