comp.lang.ada
 help / color / mirror / Atom feed
* Getting environment values in POSIX from terminated child process
@ 1998-08-04  0:00 Michael Reed
  1998-08-08  0:00 ` Lieven Marchand
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Reed @ 1998-08-04  0:00 UTC (permalink / raw)


In Rational Apex, I've been utilizing a simple series of POSIX
calls to execute UNIX scripts from within an ada program
(I figured them out from an amalgam of previous postings to this group,
particularly Kenneth Almquist's posting of how to execute a
system command using POSIX.
thank you! by the way...):

The main calls within this procedure are:
Start_Process(Child, "/bin/sh", Template, Arguments);

followed by a
Wait_For_Child_Process(Proc_Status, Child, Trace_Stopped => False,
  Masked_signals => All_Signals);

What I was wondering was, after the completion of the process, is there
any way I can still get my hands on the environment variables associated
with that process?  Is there some function call I can make on
Proc_Status for instance (a Termination_Status variable by the way) that
will return me the final environment associated with that process?

The reason I'm trying to figure this out is that I want to be able to
pass information from my script back to my program.  At the moment the
only way I know how to do that is to alter the error codes that are
coming back... but I would prefer that the error status was used
exclusively to return info on whether the process terminated abnormally
or not.  I thought that if I could put the relevant results into various
environment variables and then access them from my ada program, it would
be a more flexible way of passing information.

Any suggestions?

Michael Reed






^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Getting environment values in POSIX from terminated child process
  1998-08-04  0:00 Getting environment values in POSIX from terminated child process Michael Reed
@ 1998-08-08  0:00 ` Lieven Marchand
  0 siblings, 0 replies; 2+ messages in thread
From: Lieven Marchand @ 1998-08-08  0:00 UTC (permalink / raw)


Michael Reed <mreed@hercii.mar.lmco.com> writes:

> What I was wondering was, after the completion of the process, is there
> any way I can still get my hands on the environment variables associated
> with that process?  Is there some function call I can make on
> Proc_Status for instance (a Termination_Status variable by the way) that
> will return me the final environment associated with that process?

No. Once the process is finished the environment is gone. 

> 
> The reason I'm trying to figure this out is that I want to be able to
> pass information from my script back to my program.  

> Any suggestions?

* Put it in a temporary file and read the file back in. Beware of race 
conditions, multiple invocations of your program etc.

* Inter process communication. Since you work in a POSIX environment 
use one of the IPC facilities: named pipes, shared memory, sockets, ...
If you have control of the program your Ada program is executing you can
choose any of these. If you don't, giving the external program an option
to give its output into a named pipe should work.

-- 
Lieven Marchand <mal@bewoner.dma.be> 
------------------------------------------------------------------------------
Few people have a talent for constructive laziness. -- Lazarus Long




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-08-08  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-04  0:00 Getting environment values in POSIX from terminated child process Michael Reed
1998-08-08  0:00 ` Lieven Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox