@@ -589,9 +589,9 @@ where
589589 . launch ( )
590590}
591591
592- /// Provides a builder which can be used to build a restarting manager , which is a combination of a
593- /// restarter and runner, that can be used on systems both with and without `fork` support. The
594- /// restarter will start a nre process each time the child crashes or timesout .
592+ /// Provides a ` builder` which can be used to build a [`RestartingMgr`] , which is a combination of a
593+ /// ` restarter` and ` runner` , that can be used on systems both with and without `fork` support. The
594+ /// ` restarter` will start a new process each time the child crashes or times out .
595595#[ cfg( feature = "std" ) ]
596596#[ allow( clippy:: default_trait_access) ]
597597#[ derive( Builder , Debug ) ]
@@ -642,11 +642,12 @@ where
642642 ) ?;
643643
644644 // We start ourself as child process to actually fuzz
645- let ( sender, mut receiver, mut new_shmem_provider, core_id) = if std:: env:: var (
645+ let ( sender, mut receiver, new_shmem_provider, core_id) = if std:: env:: var (
646646 _ENV_FUZZER_SENDER,
647647 )
648648 . is_err ( )
649649 {
650+ // We get here if we are on Unix, or we are a broker on Windows.
650651 let core_id = if mgr. is_broker ( ) {
651652 match self . kind {
652653 ManagerKind :: Broker | ManagerKind :: Any => {
@@ -709,12 +710,19 @@ where
709710 loop {
710711 dbg ! ( "Spawning next client (id {})" , ctr) ;
711712
712- // On Unix, we fork (todo: measure if that is actually faster.)
713+ // On Unix, we fork
713714 #[ cfg( unix) ]
714- let child_status = match unsafe { fork ( ) } ? {
715- ForkResult :: Parent ( handle) => handle. status ( ) ,
716- ForkResult :: Child => {
717- break ( sender, receiver, self . shmem_provider . clone ( ) , core_id)
715+ let child_status = {
716+ self . shmem_provider . pre_fork ( ) ?;
717+ match unsafe { fork ( ) } ? {
718+ ForkResult :: Parent ( handle) => {
719+ self . shmem_provider . post_fork ( false ) ?;
720+ handle. status ( )
721+ }
722+ ForkResult :: Child => {
723+ self . shmem_provider . post_fork ( true ) ?;
724+ break ( sender, receiver, self . shmem_provider . clone ( ) , core_id) ;
725+ }
718726 }
719727 } ;
720728
@@ -739,9 +747,9 @@ where
739747 ctr = ctr. wrapping_add ( 1 ) ;
740748 }
741749 } else {
742- // We are the newly started fuzzing instance, first, connect to our own restore map.
750+ // We are the newly started fuzzing instance (i.e. on Windows), first, connect to our own restore map.
751+ // We get here *only on Windows*, if we were started by a restarting fuzzer.
743752 // A sender and a receiver for single communication
744- self . shmem_provider . post_fork ( true ) ?;
745753 (
746754 LlmpSender :: on_existing_from_env ( self . shmem_provider . clone ( ) , _ENV_FUZZER_SENDER) ?,
747755 LlmpReceiver :: on_existing_from_env (
@@ -753,8 +761,6 @@ where
753761 )
754762 } ;
755763
756- new_shmem_provider. post_fork ( false ) ?;
757-
758764 if let Some ( core_id) = core_id {
759765 core_affinity:: set_for_current ( core_id) ;
760766 }
0 commit comments