LinuxCommandLibrary

systemd-stdio-bridge

Connect standard streams to systemd journal

TLDR

Forward stdin/stdout to the local system bus

$ systemd-stdio-bridge
copy

Forward stdin/stdout to a specific user's D-Bus
$ systemd-stdio-bridge --[user]
copy

Forward stdin/stdout to the local system bus within a specific container
$ systemd-stdio-bridge [[-M|--machine]] [mycontainer]
copy

Forward stdin/stdout to a custom D-Bus address
$ systemd-stdio-bridge [[-p|--bus-path]] unix:path=[/custom/dbus/socket]
copy

SYNOPSIS

systemd-stdio-bridge

DESCRIPTION

systemd-stdio-bridge is an internal utility program within the systemd suite, primarily designed to act as a robust bridge for standard input, output, and error streams (stdin, stdout, stderr). Its main purpose is to connect these I/O streams between a parent process, such as systemd-run or systemd-nspawn, and a child process that might be operating within a different control group (cgroup) or isolated namespace.

Users typically do not invoke this command directly. Instead, systemd itself spawns systemd-stdio-bridge to manage I/O redirection, particularly when creating transient services or scopes (e.g., via systemd-run --scope) or when launching lightweight containers (using systemd-nspawn). The bridge ensures that the I/O streams of the wrapped process are correctly linked back to the invoking terminal or parent process, even when the wrapped process's cgroup changes or it runs in a sandboxed environment. It handles complex terminal interactions, including pushing input back into the controlling terminal's buffer using TIOCSTI ioctl and forwarding SIGWINCH signals for terminal window size changes. This utility is crucial for enabling seamless and interactive integration of temporary processes and containers within the systemd ecosystem.

CAVEATS

systemd-stdio-bridge is an internal utility of the systemd suite and is not intended for direct user invocation. Its behavior is tightly coupled with systemd's internal mechanisms, and it primarily relies on inheriting specific file descriptors and environment variables from its parent process. Direct use or modification of its behavior is unsupported and may lead to unexpected results or system instability.

It is mainly used by commands like systemd-run --scope and systemd-nspawn to manage I/O for transient services and containers. Debugging issues related to this bridge usually requires investigating the systemd component that spawned it.

ENVIRONMENT AND FILE DESCRIPTORS

systemd-stdio-bridge's behavior is heavily influenced by the file descriptors and environment variables it inherits from its parent process. It expects to receive standard I/O streams (stdin, stdout, stderr) as specific file descriptors, which it then bridges to the child process it manages. It also respects terminal-related environment variables for proper interaction with the controlling terminal.

HISTORY

systemd-stdio-bridge was introduced as an integral part of the systemd project to address complex I/O redirection challenges that arose with the introduction of transient units and containerization features. Its development focused on ensuring seamless standard I/O (stdin, stdout, stderr) connectivity for processes managed by systemd, especially those running in transient scopes or within containers (like with systemd-nspawn). It specifically tackles issues related to terminal control, such as handling SIGWINCH signals for window resizing and pushing input back to the terminal via TIOCSTI. This utility has been a foundational internal component, enabling systemd's powerful process management features to maintain proper interactive terminal behavior across various process environments.

SEE ALSO

Copied to clipboard