Skip to main content
SerenityOS uses a type-safe, high-level IPC (Inter-Process Communication) system called LibIPC for communication between processes. This system is fundamental to the microkernel-inspired architecture, enabling services and applications to interact efficiently.

IPC Overview

LibIPC provides:
  • Type-safe message passing between processes
  • Automatic serialization/deserialization
  • Request-response and one-way messaging
  • File descriptor passing
  • Code generation from interface definitions

Architecture

The IPC system consists of several components:

IPC Definition Language

IPC interfaces are defined in .ipc files using a simple DSL:

Message Types

Request-Response Messages

Use => syntax for synchronous request-response:
  • Client sends request and blocks waiting for response
  • Server processes request and sends response
  • Return value delivered to client

One-Way Messages

Use =| syntax for asynchronous one-way messages:
  • Client sends message and continues immediately
  • Server processes message when received
  • No response sent back to client

Code Generation

The IPC compiler (Meta/Lagom/Tools/CodeGenerators/IPCCompiler/) generates C++ code from .ipc files:
Generated ConnectionToServer class:

Serialization

LibIPC automatically serializes and deserializes messages:

Supported Types

  • bool: Boolean
  • i8, i16, i32, i64: Signed integers
  • u8, u16, u32, u64: Unsigned integers
  • float, double: Floating point
  • String: UTF-8 string
  • ByteString: Byte string
  • StringView: Non-owning view (serialize as String)
  • Vector<T>: Dynamic array
  • HashMap<K, V>: Hash map
  • Optional<T>: Maybe type
  • Any type with IPC encoding support
  • Gfx types (IntRect, IntPoint, Color, etc.)
  • File descriptors via IPC::File
  • Bitmaps via special [Bitmap] syntax

Custom Type Encoding

To make a custom type IPC-serializable:

File Descriptor Passing

IPC supports passing file descriptors between processes:
The [File] and [Bitmap] syntax indicates file descriptor transfer:
  • [File]: Transfers a file descriptor
  • [Bitmap]: Transfers a shared memory region containing a bitmap

Connection Lifecycle

Client Side

1

Create Connection

2

Send Messages

3

Handle Events

Server Side

1

Implement Connection Handler

2

Accept Connections

Common IPC Patterns

Service Discovery

Services listen on well-known socket paths:

Multi-Client Services

Services handle multiple clients simultaneously:

Request-Response with Timeout

Event Loop Integration

IPC integrates seamlessly with LibCore’s event loop:
See Event Loop Documentation for details on the event system.

Security Considerations

Unix domain sockets use filesystem permissions:
  • Sockets in /tmp/session/%sid/ are user-private
  • Only processes with same session ID can connect
  • File permissions prevent unauthorized access
Services must validate all incoming data:
  • Limit maximum message size
  • Limit number of concurrent connections
  • Implement rate limiting for expensive operations
  • Clean up resources when clients disconnect

Real-World Examples

WindowServer Communication

ImageDecoder Service

ConfigServer

Performance Characteristics

IPC Performance:
  • Unix domain sockets are very fast (local communication)
  • Zero-copy for file descriptor passing
  • Minimal serialization overhead
  • Async messages have near-zero latency
  • Sync messages have ~µs round-trip time

Debugging IPC

Tools for debugging IPC issues:

Further Reading

Event Loop

How IPC integrates with the event system

Services

Learn about system services that use IPC

LibIPC Source

Explore LibIPC implementation

Example .ipc Files

Study real IPC definitions in Userland/Services/