|
AW: Query on having environment of Parent in child process...
|
06/20/2008 4:40 AM
post9454
|
AW: Query on having environment of Parent in child process...
Hi,
you could provide a complete (extended) environment explicitly as the
last argument to the spawn() call, but that'd call for a bit of work.
I think the easiest would be to do
setenv(a,a_val);
setenv(b,b_val);
spawn( ..., NULL ); // envp=NULL --> inherit environment
setenv(b,NULL); // unset b
- Thomas
> -----Ursprungliche Nachricht-----
> Von: Amit Gourgonda [mailto:amitg@openclovis.com]
> Gesendet: 20 June 2008 07:40
> An: ostech-core_os
> Betreff: Query on having environment of Parent in child process...
>
>
> Hi,
>
> I am porting an application from Linux to QNX. The
> application has threads and also does fork+exec. The part of
> code is as follows.
>
> setenv(a);
> if(fork() == 0)
> {
> setenv(b);
> }
> else
> {
> return;
> }
> execvp();
>
> I read from the netrino programing document that process
> having threads fail to fork. And instead of fork+exec I have
> to call spawn(). But how do I get the environment of parent
> and also some environment set after fork() specifically for
> the child process?
>
> Thank you.
> Amit
>
>
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post9449
>
>
|
|
|
|
Re: Query on having environment of Parent in child process...
|
06/20/2008 8:01 AM
post9462
|
Re: Query on having environment of Parent in child process...
spawn() accepts an environment pointer which can be used to "construct"
an environment of your choice for the spawn()'d process. If you pass
NULL, your spawn()'d process will inherit the parents environment.
Amit Gourgonda wrote:
> Hi,
>
> I am porting an application from Linux to QNX. The application has threads and also does fork+exec. The part of code
is as follows.
>
> setenv(a);
> if(fork() == 0)
> {
> setenv(b);
> }
> else
> {
> return;
> }
> execvp();
>
> I read from the netrino programing document that process having threads fail to fork. And instead of fork+exec I have
to call spawn(). But how do I get the environment of parent and also some environment set after fork() specifically for
the child process?
>
> Thank you.
> Amit
>
>
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post9449
>
>
|
|
|