Skip to content

setproctitle crashes after a fork on MacOS #113

@Aegdesil

Description

@Aegdesil

Using this code, setproctitle crashes after a forked process is started in a thread on Mac OS.

import multiprocessing as mp
from threading import Thread

from setproctitle import setproctitle


def foo():
    setproctitle("title in child")


def thread():
    p = mp.Process(target=foo)
    p.start()
    p.join()
    print(p.exitcode)  # returns -6 on failure 0 on success


if __name__ == "__main__":
    # Setting to spawn solves the problem
    mp.set_start_method("fork")
    # Setting a title in the parent before the process starts also solves the problem
    # setproctitle("title in parent")
    t = Thread(target=thread)
    t.start()
    t.join()

I get these logs:

objc[75525]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[75525]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
-6

Python version: 3.7.8
Setproctitle version: 1.3.1
Mac OS version: 12.5

Maybe #111 is related ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions