Skip to main content

GC_set_handle_fork

Function GC_set_handle_fork 

Source
pub unsafe extern "C" fn GC_set_handle_fork(arg1: c_int)
Expand description

Overrides the default handle-fork mode. A nonzero value means GC should install proper pthread_atfork handlers. Has effect only if called before the collector initialization. Clients should call GC_set_handle_fork() with nonzero argument if going to use fork with the GC functions called in the child process. (Note that such client and at-fork handler activities are not fully POSIX-compliant.) GC_set_handle_fork() instructs GC_init to setup GC fork handlers using pthread_atfork(), the latter might fail (or, even, absent on some targets) causing abort at the collector initialization. Issues with missing (or failed) pthread_atfork() could be avoided by invocation of GC_set_handle_fork(-1) at application start-up and surrounding each fork() with the relevant GC_atfork_prepare/GC_atfork_parent/GC_atfork_child calls.