delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/11/07:35:42

From: "John M. Aldrich" <fighteer AT cs DOT com>
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
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 |
---------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019