How to change the current working directory of the child pro

Hi, All:

How can I change the current working directory of the child process started
by spawn ()? one example is that I want to change TAR’s working directory
when I start it. Thanks.

Xuedong

You can’t unless you somehow signal the child (with any of the IPC) and
the child has some code to handle it.

At that point the relation ship parent-child is irrelevant.

“Xuedong Chen” <Xuedong.Chen@IGT.com> wrote in message
news:9glgv1$j79$1@inn.qnx.com

Hi, All:

How can I change the current working directory of the child process
started
by spawn ()? one example is that I want to change TAR’s working directory
when I start it. Thanks.

Xuedong
\

What about “system(“cd newdir; tar…etc”);” instead of spawn?

“Mario Charest” <mcharest@deletezinformatic.com> wrote in message
news:9glh4c$j7m$2@inn.qnx.com

You can’t unless you somehow signal the child (with any of the IPC) and
the child has some code to handle it.

At that point the relation ship parent-child is irrelevant.

“Xuedong Chen” <> Xuedong.Chen@IGT.com> > wrote in message
news:9glgv1$j79$> 1@inn.qnx.com> …
Hi, All:

How can I change the current working directory of the child process
started
by spawn ()? one example is that I want to change TAR’s working
directory
when I start it. Thanks.

Xuedong


\

“Markus Loffler” <loffler@ces.clemson.edu> wrote in message
news:9glmm2$mgf$1@inn.qnx.com

What about “system(“cd newdir; tar…etc”);” instead of spawn?

That would only work if you restrart the child. I wouldn’t work on
existing child. Maybe I misunderstood the question.

“Mario Charest” <> mcharest@deletezinformatic.com> > wrote in message
news:9glh4c$j7m$> 2@inn.qnx.com> …

You can’t unless you somehow signal the child (with any of the IPC) and
the child has some code to handle it.

At that point the relation ship parent-child is irrelevant.

“Xuedong Chen” <> Xuedong.Chen@IGT.com> > wrote in message
news:9glgv1$j79$> 1@inn.qnx.com> …
Hi, All:

How can I change the current working directory of the child process
started
by spawn ()? one example is that I want to change TAR’s working
directory
when I start it. Thanks.

Xuedong




\

Hmm, it appears to me that the issue was spawning the child in a directory
other than the current working directory of the parent.

Another option is to chdir() the parent to the target directory before spawning
the child. Then you just chdir() back to where the parent normally lives (if
need be, that is) and the net effect is the same as the sysem() method but with
perhaps slightly lower overhead.

Having the child pre-exist and moving it around however, is a whole new
ballgame. And I forgot my glove!

-Warren “Batting 100” Peece



“Mario Charest” <mcharest@deletezinformatic.com> wrote in message
news:9gln2p$mk2$1@inn.qnx.com
|
| “Markus Loffler” <loffler@ces.clemson.edu> wrote in message
| news:9glmm2$mgf$1@inn.qnx.com
| > What about “system(“cd newdir; tar…etc”);” instead of spawn?
| >
|
| That would only work if you restrart the child. I wouldn’t work on
| existing child. Maybe I misunderstood the question.
|
| > “Mario Charest” <mcharest@deletezinformatic.com> wrote in message
| > news:9glh4c$j7m$2@inn.qnx.com
| > >
| > > You can’t unless you somehow signal the child (with any of the IPC) and
| > > the child has some code to handle it.
| > >
| > > At that point the relation ship parent-child is irrelevant.
| > >
| > > “Xuedong Chen” <Xuedong.Chen@IGT.com> wrote in message
| > > news:9glgv1$j79$1@inn.qnx.com
| > > > Hi, All:
| > > >
| > > > How can I change the current working directory of the child process
| > > started
| > > > by spawn ()? one example is that I want to change TAR’s working
| > directory
| > > > when I start it. Thanks.
| > > >
| > > > Xuedong
| > > >
| > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|

Hi, Guys, thanks for all responses!

What I actually want to do is after I coped a .tar file to hard disk (say
/hd/dir1/a.tar)from my installation CD, I want to untar this file into its
currently directory by using the tar in the CD, while my installation’s
working directory is /root, without changing the currently directory, it
tars all files into /root…

By using the chdir () and chdir () back, it did work. but one thing I am not
sure is: can I use the absolute path for TAR as the arguments of spawn ()?
all I tried so far is to use the relative path, this requires to copy TAR
utility to hard disk.

Thanks.

Xuedong

“Warren Peece” <warren@nospam.com> wrote in message
news:9glrk2$p5v$1@inn.qnx.com

Hmm, it appears to me that the issue was spawning the child in a directory
other than the current working directory of the parent.

Another option is to chdir() the parent to the target directory before
spawning
the child. Then you just chdir() back to where the parent normally lives
(if
need be, that is) and the net effect is the same as the sysem() method but
with
perhaps slightly lower overhead.

Having the child pre-exist and moving it around however, is a whole new
ballgame. And I forgot my glove!

-Warren “Batting 100” Peece



“Mario Charest” <> mcharest@deletezinformatic.com> > wrote in message
news:9gln2p$mk2$> 1@inn.qnx.com> …
|
| “Markus Loffler” <> loffler@ces.clemson.edu> > wrote in message
| news:9glmm2$mgf$> 1@inn.qnx.com> …
| > What about “system(“cd newdir; tar…etc”);” instead of spawn?
|
|
| That would only work if you restrart the child. I wouldn’t work on
| existing child. Maybe I misunderstood the question.
|
| > “Mario Charest” <> mcharest@deletezinformatic.com> > wrote in message
| > news:9glh4c$j7m$> 2@inn.qnx.com> …
|
| > > You can’t unless you somehow signal the child (with any of the IPC)
and
| > > the child has some code to handle it.
|
| > > At that point the relation ship parent-child is irrelevant.
|
| > > “Xuedong Chen” <> Xuedong.Chen@IGT.com> > wrote in message
| > > news:9glgv1$j79$> 1@inn.qnx.com> …
| > > > Hi, All:
|
| > > > How can I change the current working directory of the child
process
| > > started
| > > > by spawn ()? one example is that I want to change TAR’s working
| > directory
| > > > when I start it. Thanks.
|
| > > > Xuedong
|
|
|
|
|
|
|
|
|
|

On Mon, 18 Jun 2001 16:46:42 -0700, “Xuedong Chen”
<Xuedong.Chen@IGT.com> wrote:

Hi, Guys, thanks for all responses!

What I actually want to do is after I coped a .tar file to hard disk (say
/hd/dir1/a.tar)from my installation CD, I want to untar this file into its
currently directory by using the tar in the CD, while my installation’s
working directory is /root, without changing the currently directory, it
tars all files into /root…

By using the chdir () and chdir () back, it did work. but one thing I am not
sure is: can I use the absolute path for TAR as the arguments of spawn ()?
all I tried so far is to use the relative path, this requires to copy TAR
utility to hard disk.

You can use absolute paths with any spawn*() function. If you

want to search PATH for the executable, use spawnp*(), or spawn with
SPAWN_SEARCH_PATH flag.

ako

Thanks.

Xuedong

“Warren Peece” <> warren@nospam.com> > wrote in message
news:9glrk2$p5v$> 1@inn.qnx.com> …
Hmm, it appears to me that the issue was spawning the child in a directory
other than the current working directory of the parent.

Another option is to chdir() the parent to the target directory before
spawning
the child. Then you just chdir() back to where the parent normally lives
(if
need be, that is) and the net effect is the same as the sysem() method but
with
perhaps slightly lower overhead.

Having the child pre-exist and moving it around however, is a whole new
ballgame. And I forgot my glove!

-Warren “Batting 100” Peece



“Mario Charest” <> mcharest@deletezinformatic.com> > wrote in message
news:9gln2p$mk2$> 1@inn.qnx.com> …
|
| “Markus Loffler” <> loffler@ces.clemson.edu> > wrote in message
| news:9glmm2$mgf$> 1@inn.qnx.com> …
| > What about “system(“cd newdir; tar…etc”);” instead of spawn?
|
|
| That would only work if you restrart the child. I wouldn’t work on
| existing child. Maybe I misunderstood the question.
|
| > “Mario Charest” <> mcharest@deletezinformatic.com> > wrote in message
| > news:9glh4c$j7m$> 2@inn.qnx.com> …
|
| > > You can’t unless you somehow signal the child (with any of the IPC)
and
| > > the child has some code to handle it.
|
| > > At that point the relation ship parent-child is irrelevant.
|
| > > “Xuedong Chen” <> Xuedong.Chen@IGT.com> > wrote in message
| > > news:9glgv1$j79$> 1@inn.qnx.com> …
| > > > Hi, All:
|
| > > > How can I change the current working directory of the child
process
| > > started
| > > > by spawn ()? one example is that I want to change TAR’s working
| > directory
| > > > when I start it. Thanks.
|
| > > > Xuedong
|
|
|
|
|
|
|
|
|
|
\