Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix child process receiving ctrl-c by setting own process group #712

Merged
merged 4 commits into from
Nov 14, 2024

Conversation

haixuanTao
Copy link
Collaborator

@haixuanTao haixuanTao commented Nov 14, 2024

This fix an issue with my computer sending SIGINT to all process under dora daemon.

Documentation for the change:

    /// Sets the process group ID (PGID) of the child process. Equivalent to a
    /// `setpgid` call in the child process, but may be more efficient.
    ///
    /// Process groups determine which processes receive signals.
    ///
    /// # Examples
    ///
    /// Pressing Ctrl-C in a terminal will send `SIGINT` to all processes
    /// in the current foreground process group. By spawning the `sleep`
    /// subprocess in a new process group, it will not receive `SIGINT`
    /// from the terminal.
    ///
    /// The parent process could install a [signal handler] and manage the
    /// process on its own terms.
    ///
    /// A process group ID of 0 will use the process ID as the PGID.
    ///
    /// ```no_run
    /// # async fn test() { // allow using await
    /// use tokio::process::Command;
    ///
    /// let output = Command::new("sleep")
    ///     .arg("10")
    ///     .process_group(0)
    ///     .output()
    ///     .await
    ///     .unwrap();
    /// # }
    /// ```
    #[cfg(unix)]
    #[cfg_attr(docsrs, doc(cfg(unix)))]
    pub fn process_group(&mut self, pgroup: i32) -> &mut Command {
        self.std.process_group(pgroup);
        self
    }

From tokio doc

Copy link
Collaborator

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

binaries/daemon/src/spawn.rs Outdated Show resolved Hide resolved
binaries/daemon/src/spawn.rs Outdated Show resolved Hide resolved
haixuanTao and others added 2 commits November 14, 2024 23:47
Co-authored-by: Philipp Oppermann <[email protected]>
Co-authored-by: Philipp Oppermann <[email protected]>
@haixuanTao haixuanTao merged commit 43fe257 into dora-run Nov 14, 2024
48 of 49 checks passed
@haixuanTao haixuanTao deleted the fix-process-group branch November 14, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants