OPENSSL_FORK_PREPARE(3ossl)
π 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 withoutpthread_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:
OPENSSL_fork_prepare()should be called before afork()is done.- After the
fork()returns, the parent process should callOPENSSL_fork_parent(). - 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 π
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
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms