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 without pthread_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:

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

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