Destroying IPC Resources

IPC resources can outlive your process. When a process terminates for any reason, all files are closed and its shared memory is detached, but its IPC resources will continue to exist. If IPC resources are no longer required, they must be explicitly destroyed.

There are system calls to perform this function:

  • msgctl(3) for message queues

  • semctl(2) for semaphores

  • shmctl(2) for shared memory

The following chapters cover the specifics of these operations. There are, however, some system-wide implications of destroying IPC resources that should be noted here.

When a message queue or a semaphore set is destroyed, they are destroyed immediately. Since IPC resources are not opened like files, they do not stay open until closed. ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.