Re(2): How to get UNIX Process ID from within a running 4GL program
Posted in 1999
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
> Obnoxio The Clown escribis:
> >
> > From: "Tim Lim" <tim_lim@exe.com.au>
> > >
> > >I have a need of get the UNIX process ID of my running 4GL program.
> > >
> > >Anyone has a known answer?
> >
> > It's ugly, but:
> >
> > CREATE TEMP TABLE x (pidno int)> > RUN "echo $$ > /tmp/someuniquename"
> > LOAD FROM /tmp/someuniquename INSERT INTO temptable> >
> > and there you go.
> >
>
> This way you obtain the PID of the child process.
> The best way (that I know) without using a C function includded in the
> runner, is:
>
> $ fglgo myprog.4gi $$ # (passing the process Id as first argument)
Won't this be the pid of the shell ?
What you need is:
pid_ix.c
--------
#include <unistd.h>
int getpid_ix(int numargs)
{
pid_t p_id;
p_id = getpid();
retint((long) p_id);
return(1);
}
test.4gl
--------
MAIN
DEFINE
f_pid INTEGER
LET f_pid = getpid_ix()
DISPLAY f_pid
END MAIN
and
c4gl pid_ix.c test.4gl -o testme.4ge
>
> and inside the prog
> ...
> INTEGER pid
> ...
> LET pid = fgl_argval(1)
> ...
> I have not the manuals here, so I can't remember exactly the name of
> this function
>
> > HTH.
> >
> > ______________________________________________________
> > Get Your Private, Free Email at http://www.hotmail.com
>
> Byte byte!
> --
> Mario R. Canto
>
> mcanto@intec.unl.edu.ar
> mcanto@intec.arcride.edu.ar
> http://www.intec.unl.edu.ar/~mcanto