Skip to content
Merged
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
12 changes: 9 additions & 3 deletions src/buildstream/_cas/casdprocessmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import shutil
import stat
import subprocess
import sys
import tempfile
import time
from subprocess import CalledProcessError
Expand Down Expand Up @@ -126,16 +127,21 @@ def __init__(
self._start_time = time.time()
self._logfile = self._rotate_and_get_next_logfile()

# Create a new process group for buildbox-casd such that SIGINT won't reach it.
if sys.version_info >= (3, 11):
process_group_kwargs = {"process_group": 0}
else:
process_group_kwargs = {"preexec_fn": os.setpgrp}

with open(self._logfile, "w", encoding="utf-8") as logfile_fp:
# The frontend will take care of terminating buildbox-casd.
# Create a new process group for it such that SIGINT won't reach it.
self.process = subprocess.Popen( # pylint: disable=consider-using-with, subprocess-popen-preexec-fn
self.process = subprocess.Popen( # pylint: disable=consider-using-with
casd_args,
cwd=path,
stdout=logfile_fp,
stderr=subprocess.STDOUT,
preexec_fn=os.setpgrp,
env=self.__buildbox_casd_env(),
**process_group_kwargs
)

self._casd_channel = None
Expand Down
Loading