OPENSSL_FORK_PREPARE(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’… OPENSSL_FORK_PREPARE πŸ’…

okay bestie, so this page is about OPENSSL_fork_prepare, OPENSSL_fork_parent, and OPENSSL_fork_child β€” aka the OpenSSL fork handlers. yes, that's from crypto.h, the 3ossl manual, we been knew ✨


🌸 SYNOPSIS 🌸

first, the include, always the include:

#include <openssl/crypto.h>

okay so like, huge heads up before we even start: these functions have been deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value β€” peep openssl_user_macros(7) for the deets, iykyk.

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

three voids, no args, no returns. minimalism. main character energy fr πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: these methods are currently unused, which means no replacement methods are required or planned. literally nothing is coming to replace them, they're just vibing in the header file πŸ’€

now the actual why β€” OpenSSL has state that should be reset when a process forks. the big example: the entropy pool used to generate random numbers (and therefore encryption keys πŸ”) should not be shared across multiple programs. that would be a whole situation. so OPENSSL_fork_prepare(), OPENSSL_fork_parent(), and OPENSSL_fork_child() exist to reset this internal state.

platform check time, bestie:

  • Platforms without fork(2) will probably not need to use these functions at all. no fork, no problem 🧚
  • Platforms with fork(2) but without pthread_atfork(3) will probably need to call them manually, as described in the next paragraph.
  • Platforms like Linux that have both functions will normally not need to call these functions, because the OpenSSL library will do so automatically for you. slay, it's handled πŸ‘‘

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 β€” and they should be used according to the calling sequence described by the pthread_atfork(3) documentation, which is summarized right here:

  1. OPENSSL_fork_prepare() should be called before a fork() is done.
  2. After the fork() returns, the parent process should call OPENSSL_fork_parent().
  3. And the child process should call OPENSSL_fork_child().

that's the whole choreography. prepare β†’ fork β†’ parent/child. no cap 🫢


⭐ RETURN VALUES ⭐

OPENSSL_fork_prepare(), OPENSSL_fork_parent() and OPENSSL_fork_child() do not return values.

nothing. void. they simply are. 😌


🌈 SEE ALSO 🌈

that's the one link, go read it, it's giving required reading πŸ“š


πŸŽ€ HISTORY πŸŽ€

These functions were added in OpenSSL 1.1.1. vintage. iconic. era-defining πŸ’œ


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>.

bestie pls respect the license, it's literally the law and also it's just polite ✨

and that's the whole page! this version is 3.5.6, dated 2026-04-07, and the manual page is OPENSSL_FORK_PREPARE(3ossl) β€” mwah, go fork responsibly πŸ’–πŸ”₯

πŸ“¦ where this page comes from