Botan 3.14.1
Crypto and TLS for C&
Botan::OS::Fork_Detector Class Referencefinal

#include <os_utils.h>

Public Member Functions

bool fork_detected () const
 Fork_Detector ()
void rebaseline ()

Detailed Description

Detects if the address space of this process may have been duplicated, for example by fork(), since this object was created or last rebaselined.

Definition at line 109 of file os_utils.h.

Constructor & Destructor Documentation

◆ Fork_Detector()

Botan::OS::Fork_Detector::Fork_Detector ( )

Record the state of the current process

Definition at line 714 of file os_utils.cpp.

714: m_process_id(OS::get_process_id()), m_fork_generation(OS::get_fork_generation()) {}
uint32_t BOTAN_TEST_API get_process_id()
Definition os_utils.cpp:78
uint64_t BOTAN_TEST_API get_fork_generation()
Definition os_utils.cpp:704

References Botan::OS::get_fork_generation(), and Botan::OS::get_process_id().

Referenced by rebaseline().

Member Function Documentation

◆ fork_detected()

bool Botan::OS::Fork_Detector::fork_detected ( ) const
Returns
true if the current process may be a duplicate of the process in which this object was created or last rebaselined

Definition at line 720 of file os_utils.cpp.

720 {
721 // The PID check also catches clones which bypass the pthread_atfork handlers
722 return OS::get_process_id() != m_process_id || OS::get_fork_generation() != m_fork_generation;
723}

References Botan::OS::get_fork_generation(), and Botan::OS::get_process_id().

◆ rebaseline()

void Botan::OS::Fork_Detector::rebaseline ( )

Discard the recorded state and record the state of the current process

Definition at line 716 of file os_utils.cpp.

716 {
717 *this = Fork_Detector();
718}

References Fork_Detector().


The documentation for this class was generated from the following files: