/// Stops the pool by setting its shutting_down variable to true and
/// killing the children that are still alive. If the child process has
/// assigned its process group to its own pid, we kill the entire group.
Stops the pool by setting its shutting_down variable to true and
killing the children that are still alive. If the child process has
assigned its process group to its own pid, we kill the entire group.
Stops the pool by setting its shutting_down variable to true and killing the children that are still alive . If the child process has assigned its process group to its own pid we kill the entire group .
pub fn stop(&mut self) {
        debug!(self.logger, "Stopping all processes");
        // Send SIGTERM to all children; then release the lock and wait a little.
        // We then send SIGKILL to all remaining children.
        let children = self.children.write().unwrap();
        for (pid, _child) in children.iter() {
            signal_pid(&self.logger, Signal::SIGTERM, pid);
        }
        drop(children);
        // This wait gives time for the wait-thread to collect the results
        // of the different children.
        std::thread::sleep(Duration::from_secs(2));
        let children = self.children.write().unwrap();
        for (pid, _child) in children.iter() {
            signal_pid(&self.logger, Signal::SIGKILL, pid);
        }
        // *children = BTreeMap::default(); // also, for good measure, ensure we drop
        // all of it.
        drop(children);
        // Finally, we record the shutdown. This tells the poll-thread and
        // wait-thread that they should NOT do another iteration and return instead.
        *self.shutting_down.write().unwrap() = true;
        debug!(self.logger, "Joining poll and wait threads");
        // Wait for both worker threads to finish.
        if let Some(j) = self.poll_thread.take() {
            let _ = j.join();
        }
        if let Some(j) = self.wait_thread.take() {
            let _ = j.join();
        }
    }
pub fn stop ( & mut self ) { debug ! ( self logger " " ) ; // Send SIGTERM to all children; then release the lock and wait a little. // We then send SIGKILL to all remaining children. let children = self . children . write ( ) . unwrap ( ) ; for ( pid , _child ) in children . iter ( ) { signal_pid ( & self . logger , Signal :: SIGTERM , pid ) ; } drop ( children ) ; // This wait gives time for the wait-thread to collect the results // of the different children. std :: thread :: sleep ( Duration :: from_secs ( 2 ) ) ; let children = self . children . write ( ) . unwrap ( ) ; for ( pid , _child ) in children . iter ( ) { signal_pid ( & self . logger , Signal :: SIGKILL , pid ) ; } // *children = BTreeMap::default(); // also, for good measure, ensure we drop // all of it. drop ( children ) ; // Finally, we record the shutdown. This tells the poll-thread and // wait-thread that they should NOT do another iteration and return instead. * self . shutting_down . write ( ) . unwrap ( ) = true ; debug ! ( self logger " " ) ; // Wait for both worker threads to finish. if let Some ( j ) = self . poll_thread . take ( ) { let _ = j . join ( ) ; } if let Some ( j ) = self . wait_thread . take ( ) { let _ = j . join ( ) ; } }
Stops the pool by setting its shutting_down variable to true and
killing the children that are still alive.
Stops the pool by setting its shutting_down variable to true and killing the children that are still alive .
&mut self