SD_ID128_RANDOMIZE(3)
π SD_ID128_RANDOMIZE(3) β sd_id128_randomize π
okay bestie, so this page is all about sd_id128_randomize from the systemd manual set, and honestly? it's a little icon. it makes random 128-bit IDs and it does it flawlessly. let's get into it π«Ά
β¨ NAME β¨
sd_id128_randomize β generate 128-bit IDs. that's it. that's the whole job. and she ate π
π SYNOPSIS π
#include <systemd/sd-id128.h>
int sd_id128_randomize(sd_id128_t *ret);
like, look at that signature. clean. minimal. main character energy fr fr.
πΈ DESCRIPTION πΈ
so sd_id128_randomize() generates a brand-new randomized 128-bit ID and hands it back to you in ret. every single time you invoke it, you get a new randomly generated ID β no reruns, no repeats, no cap. and how does it pull this off? it uses the getrandom(2) kernel random number generator. the kernel said "i got you" and it did π
now, important detail, don't skip this one: sd_id128_randomize() always returns a UUID Variant 1 Version 4 compatible ID. which means it's literally guaranteed that this function will never return the ID made of all zero bits or all one bits β those are SD_ID128_NULL and SD_ID128_ALLF. so if you were sitting there worried about getting a cursed all-zeroes ID, girl, rest. it's not happening π
want more lore on the "sd_id128_t" type itself? go check sd-id128(3), she's got the whole backstory β¨
and ooh, also: the new command of systemd-id128(1) can be used as a command-line front-end for sd_id128_randomize(). so if you're a terminal kind of girlie instead of a C kind of girlie, you're covered π¦
π RETURN VALUE π
the call returns 0 on success β and on success, ret gets filled in, slay β or a negative errno-style error code. simple as that π
β NOTES β
the 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 linking ritual, nothing scary π«Ά
β οΈ okay so listen: the code described here usesgetenv(3), which is declared to be not multi-thread-safe. what that means for you is that the code calling the functions described here must not callsetenv(3)from a parallel thread. like, do not do that. bestie please. π
the recommendation? only do calls to setenv() from an early phase of the program, back when no other threads have been started yet. get it out of the way early and then everyone's happy π
π HISTORY π
sd_id128_randomize() was added in version 187. vintage. iconic. we love a long-running queen π
π¦ SEE ALSO π¦
all the besties linked in the group chat, iykyk π
and that's the whole page, babe β brought to you by systemd 261.3 on the SD_ID128_RANDOMIZE(3) page. go generate some wonderfully random IDs, you've got this πβ¨π
π¦ 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