Skip to content

Bazel does not terminate subprocesses on ^C on windows #10573

@Artem-B

Description

@Artem-B

ATTENTION! Please read and follow:

  • if this is a question about how to build / test / query / deploy using Bazel, or a discussion starter, send it to bazel-discuss@googlegroups.com
  • if this is a bug or feature request, fill the form below as best as you can.

Description of the problem / feature request:

Bazel does not terminate subprocesses on ^C on windows.
When interrupted with ^C the already launched commands continue to run.
If subsequent execution of bazel needs to restart the server, it will silently hang until the old commands have finished.
If one of the old commands is manually killed, then all remaining commands appear to be killed/cleaned up right away.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

BUILD:
genrule(
  name = "long",
  outs = ["foo"],
  cmd = "while true; do sleep 5; echo tick >> $@; done;"
)

Reproduction:

b2e80172 /tmpfs/repro > /tmpfs/bazel200.exe build long -s
INFO: Invocation ID: 042e0282-409d-4ff7-92ee-1629cae57a45
Loading: 
Loading: 0 packages loaded
Analyzing: target //:long (1 packages loaded, 0 targets configured)
INFO: Analyzed target //:long (1 packages loaded, 1 target configured).
INFO: Found 1 target...
[0 / 2] [Prepa] Executing genrule //:long
SUBCOMMAND: # //:long [action 'Executing genrule //:long', configuration: 0c76e4e27246f1cc8c360b2c11de5f1aafe2797237101c507bc86c53960ac843]
cd C:/tools/msys64/home/kbuilder/_bazel_kbuilder/iqatem7v/execroot/__main__
  SET PATH=[...]\
    SET RUNFILES_MANIFEST_ONLY=1
  C:/tools/msys64/usr/bin/bash.exe -c source external/bazel_tools/tools/genrule/genrule-setup.sh; while true; do sleep 5; echo tick >> bazel-out/x64_windows-fastbuild/bin/foo; done;
[1 / 2] Executing genrule //:long; 1s local, remote-cache

Bazel is interrupted here and we're back on the console.
The action continues to run in the background and keeps appending lines to foo:

b2e80172 /tmpfs/repro > ls -l bazel-out/x64_windows-fastbuild/bin/foo
-rw-r--r-- 1 kbuilder None 10 Jan 13 20:14 bazel-out/x64_windows-fastbuild/bin/foo
b2e80172 /tmpfs/repro > wc -l bazel-out/x64_windows-fastbuild/bin/foo
3 bazel-out/x64_windows-fastbuild/bin/foo
b2e80172 /tmpfs/repro > wc -l bazel-out/x64_windows-fastbuild/bin/foo
4 bazel-out/x64_windows-fastbuild/bin/foo
b2e80172 /tmpfs/repro > wc -l bazel-out/x64_windows-fastbuild/bin/foo
5 bazel-out/x64_windows-fastbuild/bin/foo

What operating system are you running Bazel on?

Windows Server 1809

What's the output of bazel info release?

release 2.0.0

Have you found anything relevant by searching the web?

No. Discussed w/ @meteorcloudy who suggested filing a bug.

Metadata

Metadata

Assignees

Labels

P2We'll consider working on this in future. (Assignee optional)area-WindowsWindows-specific issues and feature requeststeam-OSSIssues for the Bazel OSS team: installation, release processBazel packaging, websitetype: bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions