Reputation: 19331
Is there a way for two separate processes, built using c on Linux, to acquire some sort of per-boot pseudo-random seed/value from a global location?
In short, I have two simple processes that would like to talk to each other via a randomly-named, Unix domain socket, like so:
The idea is to randomize the file name both processes will use at boot, but they need to know some way to both determine the common path without talking to each other in advance.
I've tried using the starttime
of the init
process, by effectively doing the following command in c
:
cat /proc/1/stat | cut -d ' ' -f22
However, this value is typically the same from boot-to-boot, so it's not random enough. I was thinking of maybe writing a simple Linux kernel module that would provide this value, but that seems like overkill.
Is there some source of random data which remains the same for a single boot, but not across subsequent boots, which I could read via a non-root process in Linux?
Upvotes: 1
Views: 191
Reputation:
/proc/sys/kernel/random/boot_id
contains a random UUID generated at boot.
Upvotes: 5