SD_VARLINK_IS_CONNECTED(3)
π sd_varlink_is_connected β bestie edition π
okay so real talk, this is the sd_varlink_is_connected page from section 3 of the manual, and it's literally just two little functions that tell you what's going on with your Varlink connection. Are you connected? Are you idle? That's it. That's the whole vibe. But like, knowing is important, so let's get into it. π¦
β¨ NAME β¨
sd_varlink_is_connected, sd_varlink_is_idle β these two cuties let you query whether a Varlink connection object is currently connected or idle. no cap. π
β¨ SYNOPSIS β¨
#include <systemd/sd-varlink.h>
int sd_varlink_is_connected(sd_varlink *link);
int sd_varlink_is_idle(sd_varlink *link);
β¨ DESCRIPTION β¨
so like. sd_varlink_is_connected() checks whether the Varlink connection object you passed in is currently connected right now, or whether it's already been fully disconnected. just a lil vibe check on your link. π
then sd_varlink_is_idle() checks whether that same Varlink connection object is currently connected but idle. And what does idle even mean here? It means the connection may accept a method call for enqueuing (that's if you're on the client side of a Varlink connection), or it's waiting for more incoming method calls to arrive (that's if you're on the server side of a Varlink connection). either way she's connected, she's just chillin'. π§
β¨ RETURN VALUE β¨
okay here's the receipts:
- If the connection is currently connected,
sd_varlink_is_connected()returns a positive non-zero value. π - If it's disconnected, it returns
0. - If the connection is currently idle,
sd_varlink_is_idle()returns a positive non-zero integer. - If not, it returns
0. - On failure, both functions return a negative errno error code. π
Errors
Returned errors may indicate the following problems:
-EINVALβ the specified Varlink connection is invalid. like bestie that's not a real link, what are you doing. π
β¨ NOTES β¨
The functions described here are available as a shared library, and you can compile against and link to them with the libsystemd pkg-config(1) file. yes it's giving build system, slay. π
The code described here uses getenv(3), which is declared to be not multi-thread-safe. This means that 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 yet. like, handle your environment stuff before the group chat gets busy, fr fr. π«Ά
β οΈ seriously though,getenv(3)is not multi-thread-safe here andsetenv(3)from a parallel thread is a no. early-phasesetenv()only. that's the rule. π₯
β¨ HISTORY β¨
sd_varlink_is_connected()was added in version 259.sd_varlink_is_idle()was added in version 257.
so is_idle is the older sister and is_connected is the baby of the family. iconic honestly. πΈ
β¨ SEE ALSO β¨
iykyk. go read those too, bestie. πβ
and that's the whole page!! this was systemd version 262.1, and yeah the page is SD_VARLINK_IS_CONNECTED(3) β mwah, love that for us. ππβ¨
π¦ where this page comes from
- arch rolling: systemd-libs 262.1-1 Β· LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later WITH Linux-syscall-note
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms