OPENSSL_FORK_PREPARE(3ossl)
π OPENSSL_FORK_PREPARE π
okay bestie, gather round, because today we're talking about the OpenSSL fork handlers: OPENSSL_fork_prepare, OPENSSL_fork_parent, and OPENSSL_fork_child β straight out of the 3ossl manual, no cap. β¨
πΈ NAME πΈ
OPENSSL_fork_prepare, OPENSSL_fork_parent, OPENSSL_fork_child β the OpenSSL fork handlers. yes girl, all three, they come as a lil trio π«Ά
β¨ SYNOPSIS β¨
#include <openssl/crypto.h>
okay so heads up: 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 π
void OPENSSL_fork_prepare(void);
void OPENSSL_fork_parent(void);
void OPENSSL_fork_child(void);
π¦ DESCRIPTION π¦
so here's the tea: these methods are currently unused, and because of that, no replacement methods are required or planned. they're justβ¦ vibing. existing. iconic but unemployed π
here's the why tho β 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. and that's literally the whole job of OPENSSL_fork_prepare(), OPENSSL_fork_parent(), and OPENSSL_fork_child(): resetting that internal state. π₯
now, which platforms care?
- Platforms without
fork(2)will probably not need to use these functions. you're off the hook, babes π - Platforms with
fork(2)but withoutpthread_atfork(3)will probably need to call them manually, as described in the following paragraph. it's giving "you have to do it yourself, sorry bestie" π - Platforms such as Linux that have both functions will normally not need to call these functions, as the OpenSSL library will do so automatically. the library said "i got you" π
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:
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().
periodt. that's the order, don't freestyle it. π
π RETURN VALUES π
OPENSSL_fork_prepare(), OPENSSL_fork_parent() and OPENSSL_fork_child() do not return values.
nothing. nada. zero. they give you nothing back and honestly? respect. main character energy with no receipts π
π SEE ALSO π
β HISTORY β
these functions were added in OpenSSL 1.1.1. throwback era π¦
π 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>.
okay that's the whole page, bestie, you ate that π«Ά and just so you know exactly which one you're reading: this is OpenSSL 3.5.9, dated 2026-09-29, from the OPENSSL_FORK_PREPARE(3ossl) manual. mwah πβ¨
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms