SD-VARLINK(3)
π
SD-VARLINK(3) β like, the whole sd-varlink manual page, bestie β¨
okay so welcome to sd-varlink (section 3 of the manual, if we're being official about it) β literally the whole glow-up guide to Varlink IPC, and I'm gonna walk you through every single bit of it π«Ά
πΈ NAME πΈ
sd-varlink β APIs for Varlink IPC. that's it, that's the name, and it ate π
β¨ SYNOPSIS β¨
#include <systemd/sd-varlink.h>
pkg-config --cflags --libs libsystemd
like yes, those two lines, copy them, love them, put them in your build π
π¦ DESCRIPTION π¦
so sd-varlink.h is part of libsystemd(3) and it's the header that gives you APIs for implementing Varlink IPC clients and services. both!! versatile icon behavior π
if you wanna know more about Varlink IPC itself, the link is https://varlink.org/ β go read, it's giving documentation excellence π
Varlink IPC uses JSON[1] as its marshalling format. and the sd-varlink API relies on the sd-json(3) API for all the JSON serialization, deserialization and manipulation. so it's not doing JSON alone, it's got backup π
π Canonical encoding rules π
okay this part is lowkey important so pay attention bestie:
sd-varlink omits the "parameters" member on the wire in replies, errors, and notifications when there are no parameters to transmit. why? because it reduces message size and avoids ambiguity β efficiency slay β¨
receivers must be tolerant and accept any of the following encodings for the absence of parameters:
- an omitted
"parameters"key β this one is the preferred vibe π - a JSON
nullvalue - an empty object
{}
and when decoding, sd-varlink treats JSON null as if the member was omitted. no cap, it just handles it π
also the varlinkctl(1) tool makes all the functionality implemented by sd-varlink available from the command line, so you can absolutely do this in your terminal, main character energy fr fr π₯
π NOTES π
functions described here are available as a shared library, which you can compile against and link to with the libsystemd pkg-config(1) file. standard, iconic, no notes π
but here's the caveat so listen up: the code described here uses getenv(3), which is declared to be not multi-thread-safe. which means the code calling the functions described here must not call setenv(3) from a parallel thread. the recommendation is to only do calls to setenv() from an early phase of the program, when no other threads have been started. like do it early or don't do it at all, periodt π«Ά
bestie this is a real one β don't be out here calling setenv() from a parallel thread, that's the danger zone π
π§ DIRECTORIES π§
/usr/lib/systemd/varlink-bridges/β okay so whensd_varlink_connect_url()encounters a URL with a scheme that is not natively supported, it goes looking in this directory for a bridge helper binary named after the URL scheme. the binary gets invoked the same way asexec:binaries, but with the full URL passed as the first command line argument. iconic delegation behavior π
for example: if varlinkctl introspect https://example.com/ws/sockets/io.systemd.Hostname is called, varlinkctl will look for an executable /usr/lib/systemd/varlink-bridges/https and invoke it with "https://example.com/ws/sockets/io.systemd.Hostname" as its only argument. like, that's exactly how it goes down, character for character π
β SEE ALSO β
systemd(1), sd-event(3), sd-json(3), varlinkctl(1), sd-bus(3), pkg-config(1) β go read them, they're all in the friend group π
π NOTES π
- JSON β
https://json.org/πΈ
and that's the whole page bestie, every flag, every path, every caveat, nothing skipped π
this was systemd 261.3, SD-VARLINK(3), and honestly? she ate. mwah πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libsystemd-dev 261.3-0ubuntu3 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms