Pipeline
Half duplex. Typically created by the parent process for inter-parent and child interprocess communication. Anonymous, one on one.
FD[0] Read Only//fd[1] write only int pipe (int fd[2]);
Simply execute the command line and read and write standard input and output.
if modes = = "R", return standard output//if modes = = "W", return the standard input file *popen (const char *__command, const char *__modes); int Pclose (FIL E *__stream);
FIFO (Named pipes)
Usage: The server creates a FIFO, and any other process can write to it, and the server reads the data post-processing. You can read and write more than one. An atomic operation when the size of the write data is less than PIPE_BUF.
Similar file operations, including user/group/Other people's Read and write execution permissions, delete needs unlink.
int Mkfifo (const char *__path, __mode_t __mode); int mkfifoat (int __fd, const char *__path, __mode_t __mode);
POSIX Signal Volume
Anonymous semaphore: Used by different threads of the same process. If you need to cross-process, you need to map the semaphore structure to memory.
Named semaphores: can be used directly in different processes.
Anonymous semaphore int Sem_init (sem_t *__sem, int __pshared, unsigned int __value) int Sem_destroy (sem_t *__sem);//Open existing semaphore, Oflag = 0//If you need to create a semaphore when it does not exist, Oflag = O_creat, and you must specify mode's file access and value semaphore initial value (0~sem_value_max) sem_t *sem_open (const char *__name, I NT __oflag, .../* mode_t mode, unsigned int value */); int sem_close (sem_t *__sem);//When no one uses semaphores, the int sem_unlink is automatically deleted (const char *__name);//Pint sem_wait (sem_t *__sem); int sem_timedwait (sem_t *__restrict __sem, const struct TIMESPEC *__restri CT __abstime); int sem_trywait (sem_t *__sem);//Vint Sem_post (sem_t *__sem);
Shared storage
Multiple processes use the Sh* series function with the same key.
/* The following System V style IPC functions implement a shared memory facility. The definition is found in XPG4.2. *//* Shared Memory control operation. */extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf) __throw;/* Get shared memory segment. */extern int Shmget (key_t __key, size_t __size, int __shmflg) __throw;/* Attach shared memory segment. */extern void *shmat (int __shmid, const void *__shmaddr, int __shmflg) __throw;/* Detach shared memory segment. */extern int shmdt (const void *__shmaddr) __throw;
Apue: interprocess communication