From: Marc on
slaskbrev1(a)gmail.com wrote:

> 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?
> If not, what would be a better approach?

As already mentionned, this is IPC.

One thing that wasn't mentionned is that if you can use threads instead
of forking (don't know about your application), you don't need special
communications, you can simply modify a variable in one thread and read
the new value in the other one.
From: Rainer Weikusat on
Eric Sosman <Eric.Sosman(a)sun.com> writes:
> slaskbrev1(a)gmail.com 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?
>
> Not unless they are in shared memory. (In which case they
> wouldn't be "variables" in the strict C sense, but they would
> still be "objects.")

There are two places where the C-standard does not use the term
'variable' as an adjective:

If clause-1 is a declaration, the scope of any variables it
declares is the remainder of the declaration and the entire
loop, including the other two expressions; it is reached in
the order of execution
[6.8.5.3|1]

and

A floating-point status flag is a system variable whose value is set
(but never cleared) when a floating-point exception is raised,
[7.6|1]

Everything otherwise declared is an object. C provides no way for an
application to place a variable (C++ does). Insofar the C-standard is
concerned, use of shared memory (or any other type of memory
management done by the application) is just undefined behaviour.

It is not overly complicated to find Germans with a (German) degree in
computer science advocating that use of such facilities should be
considered an error.