Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the copy-the-code domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/html/pcx3.com/wp-includes/functions.php on line 6121
Inter-process communication under Linux 🐧 - PC✗3
Inter-process communication under Linux 🐧

Inter-process communication under Linux 🐧

There are roughly the following types of inter-process communication under Linux:

  • socket
  • Pipes (including anonymous pipes for parent and child processes, named pipes)
  • Semaphore
  • Shared memory
  • Message queue

socket

Socket can be used for local inter-process communication or remote inter-process, and is the most commonly used.

Pipeline – Anonymous Pipeline

It is generally created with pipe and communicates between father and son. Close the read/write pipeline in the parent process, and close the write/read pipeline in the child process.

Pipes-named pipes

Generally use mkfifo to create. If it is not stated that the pipe is non-blocking, then a pipe opened for reading will block until a process opens the FIFO for writing. Similarly, if a pipe opened for writing will block until a process opens this FIFO for reading.

Semaphore

A process can use kill to send a signal to another process.

Shared memory

Use functions:

shmget, shmat, shmctl, shmdt

Use shmget function to get a piece of memory, and use shmat to set it to allow this process to use this shared memory. Use shmdt to delete the memory block after use.

Message queue

Use functions:

msgget, msgsnd, msgrcv, msgctl

The use steps are the same as above.

whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.