UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2012-02-24 04:54 PM

useless79
Member
Registered: 2011-10-10
Posts: 30

global variable sharing across processes

Hi,

I want a share a global variable in two processes A and B.
Is there any way to do this ? I do not want to use shared memory.

Thanks....

Offline

#2 2012-02-24 08:26 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,826
Website

Re: global variable sharing across processes

Why no shared memory?  That's the straightforward way to do it...  Any other approach would be kind of a kluge in comparison...  Basically, you'd need some IPC channel to communicate the value of the variable to each other whenever it changes in either...

Offline

#3 2012-02-25 08:45 AM

useless79
Member
Registered: 2011-10-10
Posts: 30

Re: global variable sharing across processes

any shared dynamic/static lib mechanism will help here ?
sorry i do not know ... just asking...

Offline

#4 2012-02-25 04:55 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,826
Website

Re: global variable sharing across processes

No, I don't think so...  You mean like have the global variable declared in the library and both apps link against it?  That's not going to share the value of the variable...  If that worked, then all C apps would share a single global "errno", among other things, which would be hell...  Each app gets its own private copy of all library variables; only code is shared...

Offline

#5 2012-02-25 06:53 PM

useless79
Member
Registered: 2011-10-10
Posts: 30

Re: global variable sharing across processes

thanks Rob

Offline

Board footer

Powered by FluxBB