Inter Process Communication

File

  • A record stored on disk which can be accessed by multiple processes

Signals

Network Sockets

Unix Domain Sockets

Anonymous Pipes

  • https://en.wikipedia.org/wiki/Anonymous_pipe
  • It is unidirectional data channel using stdin/stdout
  • It is FIFO
  • Bidirectional communication can be achieved using 2 anonymous pipes
  • Examples
    • | in terminal to pass output of one process to another
    • stdio transport in MCP server

Named Pipes

  • Instead of using stdin and stdout, special files are created in filesystem
  • These special files have no contents on the file system
  • They persists unless deleted unlike anonymous pipe which is ephemeral
  • It is FIFO
# create a named pipe
mkfifo my_pipe
 
# check file metadata
# prw-r--r--  1 KartikeyKumar  staff  0 28 Jun 17:13 my_pipe
ls -al my_pipe
 
 
# Terminal 1: waits for data
cat my_pipe
 
# Terminal 2: sends data to Terminal 1
echo "Hello from Terminal 2!" > my_pipe
 
# remove the named pipe
rm my_pipe

Message queue