Skip to content

Commit ac28795

Browse files
committed
import setproctitle after forking on macOS
1 parent 1febb52 commit ac28795

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mutmut/__main__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import signal
1212
import subprocess
1313
import sys
14+
import platform
1415
from abc import ABC
1516
from collections import defaultdict
1617
from configparser import (
@@ -55,7 +56,11 @@
5556
import libcst as cst
5657
import libcst.matchers as m
5758
from rich.text import Text
58-
from setproctitle import setproctitle
59+
60+
# do not import on macOS before forking, because this causes a segfault on newer versions (see #446)
61+
# on other platforms, import before forking for a small performance gain (import takes some miliseconds; re-import later on is instant)
62+
if platform.system() != 'Darwin':
63+
from setproctitle import setproctitle
5964

6065
import mutmut
6166
from mutmut.code_coverage import gather_coverage, get_covered_lines_for_file
@@ -1101,6 +1106,8 @@ def read_one_child_exit_status():
11011106
if not pid:
11021107
# In the child
11031108
os.environ['MUTANT_UNDER_TEST'] = mutant_name
1109+
# import for macOS (on other platforms, this re-import does nothing)
1110+
from setproctitle import setproctitle
11041111
setproctitle(f'mutmut: {mutant_name}')
11051112

11061113
# Run fast tests first

0 commit comments

Comments
 (0)