From be6f3b97ab6f118adb1980e4bdc7c55705186f24 Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Sun, 25 Jan 2026 09:57:20 +0100 Subject: [PATCH] Disable setproctitle on macOS to prevent segfaults setproctitle causes segfaults on macOS due to fork() safety issues introduced in newer macOS versions. The mere import of setproctitle can trigger crashes in forked worker processes. Fixes #3021 --- gunicorn/util.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gunicorn/util.py b/gunicorn/util.py index e66dbebf..16842afd 100644 --- a/gunicorn/util.py +++ b/gunicorn/util.py @@ -46,14 +46,20 @@ hop_headers = set(""" server date """.split()) -try: - from setproctitle import setproctitle - - def _setproctitle(title): - setproctitle("gunicorn: %s" % title) -except ImportError: +# setproctitle causes segfaults on macOS due to fork() safety issues +# https://github.com/benoitc/gunicorn/issues/3021 +if sys.platform == "darwin": def _setproctitle(title): pass +else: + try: + from setproctitle import setproctitle + + def _setproctitle(title): + setproctitle("gunicorn: %s" % title) + except ImportError: + def _setproctitle(title): + pass def load_entry_point(distribution, group, name):