In what ways can processes communicate?
UNIX processes on their own are boring; they are interesting when they communicate. There are many methods of “Inter-process communication”, or IPC. What are all these methods? There are many!:
write. The sender writes to a file; the receiver reads from it. USP: durability.
write. A pipe, created with
pipe, is a byte queue.
pipereturns file descriptors for both ends. Closing both ends destroys the pipe.
kill. The sender can send a signal to the receiver. A signal does not have associated data.
write. Sockets link processes over network interfaces. USP: connecting remote processes (not just local ones).
- Message queues:
mq_timedsend. A message queue is a bit like a pipe, but with a proper concept of messages (a message is a byte array).
semop. Used to protect common resources used by processes.
- Shared memory:
shmgetand friends. A single memory location can be read/written by multiple processes. USP: communication via memory, not system calls.