From 898d75122f9998205516759022b740e873e30dcc Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Thu, 5 Dec 2024 03:45:05 +0000 Subject: [PATCH] Update comments on Windows job objects --- src/bootstrap/bootstrap.py | 2 ++ src/bootstrap/src/utils/job.rs | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 762f4e653e9..9ef9ccec193 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -1184,6 +1184,8 @@ def bootstrap(args): args = [build.bootstrap_binary()] args.extend(sys.argv[1:]) env = os.environ.copy() + # The Python process ID is used when creating a Windows job object + # (see src\bootstrap\src\utils\job.rs) env["BOOTSTRAP_PARENT_ID"] = str(os.getpid()) env["BOOTSTRAP_PYTHON"] = sys.executable run(args, env=env, verbose=build.verbose, is_bootstrap=True) diff --git a/src/bootstrap/src/utils/job.rs b/src/bootstrap/src/utils/job.rs index bd2d86498c5..fb69d331d27 100644 --- a/src/bootstrap/src/utils/job.rs +++ b/src/bootstrap/src/utils/job.rs @@ -15,11 +15,12 @@ pub unsafe fn setup(build: &mut crate::Build) { /// /// Most of the time when you're running a build system (e.g., make) you expect /// Ctrl-C or abnormal termination to actually terminate the entire tree of -/// process in play, not just the one at the top. This currently works "by +/// processes in play. This currently works "by /// default" on Unix platforms because Ctrl-C actually sends a signal to the -/// *process group* rather than the parent process, so everything will get torn -/// down. On Windows, however, this does not happen and Ctrl-C just kills the -/// parent process. +/// *process group* so everything will get torn +/// down. On Windows, however, Ctrl-C is only sent to processes in the same console. +/// If a process is detached or attached to another console, it won't receive the +/// signal. /// /// To achieve the same semantics on Windows we use Job Objects to ensure that /// all processes die at the same time. Job objects have a mode of operation