OPENSSL_FORK_PREPARE(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… OPENSSL_FORK_PREPARE πŸ’…

okay bestie, welcome to the 3ossl corner of the manual-verse ✨ β€” this one's about the OpenSSL fork handlers, and honestly? It's a short one, so grab your lil strawberry drink πŸ“ and let's go.

🌸 NAME 🌸

OPENSSL_fork_prepare, OPENSSL_fork_parent, OPENSSL_fork_child β€” the OpenSSL fork handlers, no cap 🫢

✨ SYNOPSIS ✨

First things first, you gotta pull in the header:

#include <openssl/crypto.h>

okay so here's the thing πŸ‘€ β€” the following functions have been deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value. (Go check openssl_user_macros(7) for the details, iykyk.)

void OPENSSL_fork_prepare(void);
void OPENSSL_fork_parent(void);
void OPENSSL_fork_child(void);

πŸ¦‹ DESCRIPTION πŸ¦‹

So like… these methods are currently unused, and because of that, no replacement methods are required or planned. Literally none. Periodt. πŸ’€

But here's the lore: OpenSSL has state that should be reset when a process forks. For example, the entropy pool used to generate random numbers (and therefore encryption keys!! πŸ‘‘) should not be shared across multiple programs. That's the whole vibe check. The OPENSSL_fork_prepare(), OPENSSL_fork_parent(), and OPENSSL_fork_child() functions are the ones used to reset this internal state. πŸ”₯

Platforms without fork(2) will probably not need to use these functions. Platforms with fork(2) but without pthread_atfork(3) will probably need to call them manually, as described in the next paragraph. Platforms such as Linux that have both functions will normally not need to call these functions, because the OpenSSL library will do so automatically. Slay, automatic. πŸ’…

OPENSSL_init_crypto(3) will register these functions with the appropriate handler when the OPENSSL_INIT_ATFORK flag is used. For other applications, these functions can be called directly. They should be used according to the calling sequence described by the pthread_atfork(3) documentation, which is summarized here for you πŸŽ€:

  • OPENSSL_fork_prepare() should be called before a fork() is done.
  • After the fork() returns, the parent process should call OPENSSL_fork_parent().
  • …and the child process should call OPENSSL_fork_child().
fr fr, that order matters β€” prepare before, then parent-or-child depending on which side of the fork you woke up on. 🧚

⭐ RETURN VALUES ⭐

OPENSSL_fork_prepare(), OPENSSL_fork_parent() and OPENSSL_fork_child() do not return values. Nothing. Nada. Not even a lil 0. πŸ™ˆ

🌈 SEE ALSO 🌈

πŸ’œ HISTORY πŸ’œ

These functions were added in OpenSSL 1.1.1. Iconic behavior, honestly. ✨

Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie 🫢 this was OpenSSL 3.5.0, dated 2026-09-25, filed under OPENSSL_FORK_PREPARE(3ossl) β€” go forth and fork responsibly πŸ’…πŸŒΈ

πŸ“¦ where this page comes from