Skip to main content

shrub_core/shell/
job_control.rs

1//! Job management for shell instances.
2
3use std::io::Write;
4
5use crate::{error, extensions};
6
7impl<SE: extensions::ShellExtensions> crate::Shell<SE> {
8    /// Checks for completed jobs in the shell, reporting any changes found.
9    ///
10    /// # Errors
11    ///
12    /// Returns [`crate::error::ErrorKind::IoError`] if reporting a finished job
13    /// on stderr fails.
14    pub fn check_for_completed_jobs(&mut self) -> Result<(), error::Error> {
15        let results = self.jobs.poll()?;
16
17        if self.options.enable_job_control {
18            for (job, _result) in results {
19                writeln!(self.stderr(), "{job}")?;
20            }
21        }
22
23        Ok(())
24    }
25}