Loading
nixos-rebuild-ng: kill underlying remote process
`nixos-rebuild-ng` explicitly don't allocate a pseudo-TTY for SSH because this causes lots of issues depending on the use case (for example, multiplexing multiple SSH sessions). Sadly not using a pseudo-TTY also cause other issues, like the fact that using Ctrl+C (SIGINT) doesn't kill the underlying process because SSH doesn't support it. We can't really start using pseudo-TTY unless we want to overcomplicate the code for parsing results (pseudo-TTY mangles the stdout/stderr together), so we need to handle killing the underlying remote process manually. This is what this commit does, when we receive a `KeyboardInterrupt` exception while calling `run_wrapper`, we will check if it is a remote process and send a `pkill --full` with the arguments (this should ensure that we don't kill other process, but we can't guarantee it). This assumes the user has `procps` installed, but I think it is a safe assumption since this seems to be a core package. Sadly nothing we can do if the user doesn't have `procps` installed, the good thing is that the worst that can happen is that we will silent fail and the process will stay in background until it finishes. Fix #403269. (cherry picked from commit 61e61a59)