Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions bazelisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,17 @@ def make_bazel_cmd(bazel_path, argv):
def execute_bazel(bazel_path, argv):
cmd = make_bazel_cmd(bazel_path, argv)

# We cannot use close_fds on Windows, so disable it there.
p = subprocess.Popen([cmd["exec"]] + cmd["args"], close_fds=os.name != "nt", env=cmd["env"])
# If we can replace our process with the Bazel executable, that's better
# than a subprocess. (Replacing is not available on Windows.)
if os.name != "nt":
os.execve(
cmd["exec"],
[cmd["exec"]] + cmd["args"],
cmd["env"],
)

# We cannot use close_fds on Windows.
p = subprocess.Popen([cmd["exec"]] + cmd["args"], close_fds=False, env=cmd["env"])
while True:
try:
return p.wait()
Expand Down