EXECing to another program

This is a discussion on EXECing to another program within the C++ Programming forums, part of the General Programming Boards category; I'm writing a program that needs to have two processes running at the same time. I have found through some ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    21

    EXECing to another program

    I'm writing a program that needs to have two processes running at the same time. I have found through some research that the best way to do this would be to use a handler program that would exec to a processor daemon, sending the addresses of the main object to the processor daemon so that it could put those addresses into pointers, and the two programs could share the object. I would like to know if this is even feasible. The only problem I could find is that I would have to change the constant chars that were sent in the exec to int so that I could assign them to the pointers. But, I believe that there is a function in the STL that will do that.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    You are mistaken. This is not the best way, because it introduces the highly complicated problem of process memory spaces.

    In short, all modern OSs keep the memory areas of their programs entirely separate, so that a pointer in one program is usually completely meaningless in the other. What you'd have to do is create a block of shared memory and map it into both processes, but then you still can't rely on standard classes as they're not guaranteed to allocate there. And the whole thing is platform-dependent anyway, because standard C++ doesn't contain anything that deals with shared memory.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    21
    Hmmmmmmmm, I had forgotten about seperate memory sections. Looks like back to the drawing board! Is there any way for me to run two programs and have them share an object?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  2. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21