From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Sharing global variable Date: Mon, 09 Jun 1997 20:21:26 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 25 Message-ID: <339C65C6.62E4@cs.com> References: <339BB7B0 DOT 2EAD AT emic DOT ucl DOT ac DOT be> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp105.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Michael Goffioul wrote: > > I'd like to know if it's possible for a called program (with "exec" > command) to access the same global variable as the calling program, > a sort of shared variable between 2 programs. > > For example, if a static variable "a" is declared in a header file > included in 2 differents programs "prog1.exe" and "prog2.exe". If > "prog1.exe" calls "prog2.exe", is it possible that prog2 uses the same > global variable than prog1 ? Adding to what Eli said, I'll also mention that you can allocate a buffer in conventional memory to store your data, and pass the address of that buffer to the child program. This is also nonportable, but less so than fiddling with global selectors. ;) I don't recall the exact names of the functions to use offhand, but they are in the libc documentation. -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com | | Proud owner of what might one | http://www.cs.com/fighteer | | day be a spectacular MUD... | Plan: To make Bill Gates suffer | ---------------------------------------------------------------------