-1

I have a program 'P' and P is executed in terminal A. Let's call it process A. While process A is running, terminal B is opened and executes P as process B.

How can I make process A find process B and exchange data with each other? Someone told me to implement it with MPI but I haven't found any material telling me how.

I also appreciate that if anyone can tell me how to make these two process read and write the same variable (same address in memory). This solves my problem, too.

Zulan
  • 21,896
  • 6
  • 49
  • 109
idwwwoqq808
  • 23
  • 1
  • 5
  • My program is written in C++. Sorry for not mentioning that. – idwwwoqq808 May 10 '19 at 18:28
  • 1
    Look up shared memory. – Seva Alekseyev May 10 '19 at 18:47
  • 1
    There are many many ways to exchange data between processes. You need to specify your requirements more clearly in order to figure out the appropriate methods in your case. What are the processes doing? How are they interacting with the user? How much data needs to be transferred? – Zulan May 10 '19 at 18:47
  • Unix-domain sockets, message queues, and shared memory are the easiest methods to use for this. – Barmar May 10 '19 at 19:10
  • 2
    Possible duplicate of [Which Linux IPC technique to use?](https://stackoverflow.com/q/2281204/608639), [Comparing Unix/Linux IPC](https://stackoverflow.com/q/404604/608639), etc. – jww May 10 '19 at 20:05

1 Answers1

0

There are lots of options, but in most cases I think you'll find that named pipes/fifo will meet your needs.

See mkfifo, which creates a named pipe on the filesystem; that pipe can then be opened and accessed using standard open/read/write like a file for interprocess communications.

Alex Broadwin
  • 1,288
  • 11
  • 23