Re: Get variables from forked child
- From: Lew Pitcher <lpitcher@xxxxxxxxxxxx>
- Date: Wed, 23 Apr 2008 10:28:05 -0400
In comp.unix.programmer, slaskbrev1@xxxxxxxxx wrote:
Hi.
Im writing a small appliction in C under linux 2.6.24.
I use fork() to create a child process which does some computing
(based on a listening socket).
Is it somehow possible that from the parent (main method), access
variables set in the child?
Yes and no.
A child process' environment (internal variables, files, etc) is separate
and hidden from the parent process. Normally, the parent process cannot
access anything within the child process at all.
To permit the parent process to retrieve data from the child process, both
the child process /and/ the parent process must /share/ a communications
method. You can use pipes or sockets or files, have the child write the
results to the I/O mechanism, and have the parent read the results from the
I/O mechanism. You can also use "shared memory", have the child write the
results to a known memory location, and have the parent read the results
from the known memory location.
If not, what would be a better approach?
Thanks!
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------
.
- References:
- Get variables from forked child
- From: slaskbrev1
- Get variables from forked child
- Prev by Date: Get variables from forked child
- Next by Date: Re: Get variables from forked child
- Previous by thread: Get variables from forked child
- Next by thread: Re: Get variables from forked child
- Index(es):
Relevant Pages
|
|