Unix Programming - Re: How do I: Main thread spawn child threads, which child processes...control those

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2004 > Re: How do I: Main thread spawn child threads, which child processes...control those





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: How do I: Main thread spawn child threads, which child processes...control those
Barry Margolin

2004-01-23, 5:16 pm

In article <3FD14000.1060409@gurugeek.EXAMPLENOSPAM.com>,
Jeff Rodriguez <newsgroup1@gurugeek.EXAMPLENOSPAM.com> wrote:
quote:

> Actually, I just found this little tidbit:
>
>
> Does anyone have objections to using that method for any reason? I would
> think
> this cause duplicates of much of the memory already in use by the parent
> process, is that memory free()'d when I use one of the exec*() functions?



exec() completely replaces the process's memory with that of the new
program. Think about it: except for the init process that's created at
boot time, every process on Unix was created by forking and usually
exec'ing something immediately thereafter. Every program run from the
shell was fork/exec'ed by the shell. By the time you get to an
application program, you're at least 4 levels deep in this, and it would
make little sense if each one of them were layered on top of a copy of
the parent rather than replacing it.
quote:

> Now what if I wanted to do bi-directional communication with that process...
> do
> the exec*() functions destory all variables (pertains to previous paragraph).
> If
> I didn't want to use a file in the operating system, how would I communicate
> between the two?



Use a pair of pipes, one for parent->child and the other for
child->parent. Some operating systems support bidirectional
communications through a single pipe, but if portability is a concern
you shouldn't depend on this.

--
Barry Margolin, barmar@alum.mit.edu
Woburn, MA
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com