There are various ways two (Unix) processes can exchange information, depending on the needs, and how (or when) they are started. Say, process A wants to send information to process B. Some options are:
- Signals. Con: only one bit of information can be send. Both processes need to be running at the same time. And process A needs to have the appropriate permission to send a signal.
- Environment variables. Con: This requires process A to be (great)*parent of process B in the process tree.
- Command line arguments. Con: process A needs to be the parent of process B.
- Pipe. Pro: bidirectional communication is possible. Con: synchronisation is harder. Deadlock may occur.
- Shared memory. Pro: can exchange complex values. Data can be shared among multiple processes. Data can live past the life time of the process. Con: Many programmers find it hard to do it right. Often requires use of semaphores. May be hard to carry over to a different platform. Data can live past the life time of the process.
- Local external resources (files, for instance). Pro: Processes don't need to run at the same time. Con: Needs synchronisation (locking). Need to take care files get removed.
- Non-local external resources (databases, for instance). Pro: Processes don't need to run at the same time, or even on the same machine. Con: Requires setting up the external resource, which may be costly. It's far from being the simplest or fastest solution.
And then I probably forgot a few.