SD_BUS_MESSAGE_COPY(3)
π
SD_BUS_MESSAGE_COPY(3) β like, the sd_bus_message_copy manual page, section 3, bestie β¨
Okay so before we even start, you should know this is the section 3 page for sd_bus_message_copy, and it's gonna be so good for you. Buckle up π
πΈ NAME πΈ
sd_bus_message_copy β copy the contents of one message to another. That's it. That's the whole gig. Copy-paste but make it D-Bus β¨
π¦ SYNOPSIS π¦
#include <systemd/sd-bus.h>
int sd_bus_message_copy(sd_bus_message *m, sd_bus_message *source,
int all);
Three args, no drama. Here's the signature, literally character for character, do not touch it π
π DESCRIPTION π
So sd_bus_message_copy() copies the contents from message source to m. (Yes, m is the destination, and no, the naming is not gonna get cuter, we deal π.)
Now here's the tea about all:
- If
allis false β a single complete type gets copied (basic or container). Just one. A little guy. π - If
allis true β the contents get copied until the end of the currently open container, or the end ofsource. Whichever comes first. Full send π
π₯ RETURN VALUE π₯
Okay so the return value is doing two jobs and you have to know which one you're in:
- On success, this call returns true if anything was copied, and false if there was nothing to copy. So like,
true= we ate,false= empty plate, no crumbs π«Ά - On failure, it returns a negative errno-style error code. Sad girl hours, but at least it's descriptive.
π Errors
Returned errors may indicate the following problems β memorise these, iykyk:
-EINVALβsourceormareNULL. You passed me a ghost π»-EPERMβ Messagemhas been sealed, orsourcehas not been sealed. Sealing rules are NOT optional, bestie π«-ESTALEβ Destination message is in invalid state. It's giving expired milk π-ENXIOβ Destination message cannot be appended to. Nowhere to put the stuff π-ENOMEMβ Memory allocation failed. Computer said "no β€οΈ"
β NOTES β
Facts time, no cap:
- Functions described here are available as a shared library, which can be compiled against and linked to with the
libsystemdpkg-config(1)file. Iconic build system behaviour, honestly π₯ - 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. And multiple independent objects may be used from different threads in parallel β so like, separate objects can do their own thing, but no sharing one object mid-operation, that's a crime π
- The code described here uses
getenv(3), which is declared to be not multi-thread-safe. This means the code calling the functions described here must not callsetenv(3)from a parallel thread. It is recommended to only do calls tosetenv()from an early phase of the program when no other threads have been started.
π«Ά Real talk: thatgetenv/setenvthing is a genuine caveat, not a vibe. Do yoursetenv()calls early, before any other threads have been started. Future you will be obsessed with past you for this.
π SEE ALSO π
Go read these next, they're also main character energy:
and that's the whole page, periodt π β¨
This one ships in systemd 261.3 β the source/version tag on the footer is systemd 261.3, so that's your version right there, mwah π (and the date spot on the footer is just the classic SD_BUS_MESSAGE_COPY(3) repeat, so no date for us today, we vibe anyway π¦)
π¦ 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