Skip to content

fix: use random_int to support forks - #2369

Open
Litarnus wants to merge 2 commits into
5.xfrom
fix/fork-safe-sampling
Open

Litarnus wants to merge 2 commits into
5.xfrom
fix/fork-safe-sampling

Conversation

@Litarnus

Copy link
Copy Markdown
Collaborator

Replaces mt_rand with random_int to support better randomness in forked processes. mt_rand will seed it once and forks will inherit the seeded state, meaning that the forked processes will produce the same decisions as their parents.

To make things easier, this PR also introduces a new utility helper that generates random numbers with a fallback in case no OS cryptography is available. Also has the side effect of being nicer to read

@Litarnus
Litarnus requested a review from stayallive November 16, 2026 13:15
@Litarnus Litarnus self-assigned this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant