From ac287956425964edcbba8b65cd262b73a4e18c13 Mon Sep 17 00:00:00 2001 From: A_A <21040751+Otto-AA@users.noreply.github.com> Date: Thu, 30 Oct 2025 21:30:25 +0100 Subject: [PATCH] import setproctitle after forking on macOS --- mutmut/__main__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mutmut/__main__.py b/mutmut/__main__.py index bb20089a..b0bdaa07 100644 --- a/mutmut/__main__.py +++ b/mutmut/__main__.py @@ -11,6 +11,7 @@ import signal import subprocess import sys +import platform from abc import ABC from collections import defaultdict from configparser import ( @@ -55,7 +56,11 @@ import libcst as cst import libcst.matchers as m from rich.text import Text -from setproctitle import setproctitle + +# do not import on macOS before forking, because this causes a segfault on newer versions (see #446) +# on other platforms, import before forking for a small performance gain (import takes some miliseconds; re-import later on is instant) +if platform.system() != 'Darwin': + from setproctitle import setproctitle import mutmut from mutmut.code_coverage import gather_coverage, get_covered_lines_for_file @@ -1101,6 +1106,8 @@ def read_one_child_exit_status(): if not pid: # In the child os.environ['MUTANT_UNDER_TEST'] = mutant_name + # import for macOS (on other platforms, this re-import does nothing) + from setproctitle import setproctitle setproctitle(f'mutmut: {mutant_name}') # Run fast tests first