// a worker keeps running V after fork; its collector must forget vanished threads. module engine $if gcboehm ? { #include } fn C.GC_atfork_prepare() fn C.GC_atfork_parent() fn C.GC_atfork_child() fn fork_process() i32 { // libgc documents these as no-ops when pthread_atfork handles the collector. // explicit calls also support V builds whose collector has no automatic hooks. $if gcboehm ? { C.GC_atfork_prepare() } child := C.fork() failure := if child < 0 { C.errno } else { 0 } $if gcboehm ? { if child == 0 { C.GC_atfork_child() } else { C.GC_atfork_parent() } } if child < 0 { C.errno = failure } return child }