---
name: "sd_bus_wait"
section: "3"
platform: "linux"
package: "systemd-libs"
version: "262.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/sd_bus_wait"
---

# sd\_bus\_wait(3)

Wait for I/O on a bus connection

## NAME

sd\_bus\_wait - Wait for I/O on a bus connection

## SYNOPSIS

```
#include <systemd/sd-bus.h>
```

**int sd\_bus\_wait(sd\_bus \****bus***, uint64\_t** *timeout\_usec***);**

## DESCRIPTION

**sd\_bus\_wait()** synchronously waits for I/O on the specified bus connection object. This function is supposed to be called whenever [**sd\_bus\_process**(3)](/sd_bus_process/3.md) returns zero, indicating that no work is pending on the connection. Internally, this call invokes [**ppoll**(2)](/ppoll/2.md), to wait for I/O on the bus connection. If the *timeout\_usec* parameter is specified, the call will block at most for the specified amount of time in μs. Pass **UINT64\_MAX** to permit it to sleep indefinitely.

After each invocation of **sd\_bus\_wait()** the **sd\_bus\_process()** call should be invoked in order to process any now pending I/O work.

Note that **sd\_bus\_wait()** is suitable only for simple programs as it does not permit waiting for other I/O events. For more complex programs either connect the bus connection object to an external event loop using [**sd\_bus\_get\_fd**(3)](/sd_bus_get_fd/3.md) or to an [**sd-event**(3)](/sd-event/3.md) event loop using [**sd\_bus\_attach\_event**(3)](/sd_bus_attach_event/3.md).

## RETURN VALUE

If any I/O was seen, a positive value is returned, zero otherwise. If an error occurs, a negative *errno*-style error code is returned.

### Errors

Returned errors may indicate the following problems:

**-EINVAL**

An invalid bus object was passed.

**-ECHILD**

The bus connection was allocated in a parent process and is being reused in a child process after **fork()**.

**-ENOTCONN**

The bus connection has been terminated already.

## NOTES

Functions described here are available as a shared library, which can be compiled against and linked to with the **libsystemd** [**pkg-config**(1)](/pkg-config/1.md) file.

All functions listed here are thread-agnostic and only a single thread may operate on a given object at any given time. Different threads may access the same object at different times. Multiple independent objects may be used from different threads in parallel.

The code described here uses [**getenv**(3)](/getenv/3.md), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call [**setenv**(3)](/setenv/3.md) from a parallel thread. It is recommended to only do calls to **setenv()** from an early phase of the program when no other threads have been started.

## HISTORY

**sd\_bus\_wait()** was added in version 240.

## SEE ALSO

[**systemd**(1)](/systemd/1.md), [**sd-bus**(3)](/sd-bus/3.md), [**sd\_bus\_process**(3)](/sd_bus_process/3.md), [**sd\_bus\_get\_fd**(3)](/sd_bus_get_fd/3.md), [**sd-event**(3)](/sd-event/3.md), [**sd\_bus\_attach\_event**(3)](/sd_bus_attach_event/3.md)
