Skip to content

Using getproctitle() changes the result of getthreadtitle()? #140

@wimglenn

Description

@wimglenn

I found something that seems undesirable - when using getproctitle() the result returned by getthreadtitle() seems to mutate.

Minimal reproducer:

$ cat issueexample.py
from setproctitle import getthreadtitle, getproctitle
print("0.", getthreadtitle(), getproctitle())
print("1.", getthreadtitle(), getproctitle())

Demo:

$ python3 issueexample.py
0. python3 python3 issueexample.py
1. python3 issueex python3 issueexample.py

The change also affects the /proc/{pid}/task/{pid}/comm file.

Shouldn't using getters not modify the results in any way?

I'm on Linux (RHEL8) using setproctitle 1.3.3. I also could reproduce this in a debian container (docker.io/library/python:3.12)

Not sure if related, but with debug logging on I also see a message about "setup was called more than once!":

$ SPT_DEBUG=1 python issueexample.py
[SPT]: module init
[SPT]: reading argc/argv from Python main
[SPT]: found 2 arguments
[SPT]: walking from environ to look for the arguments
[SPT]: found environ at 0x7fffffffb5d4
[SPT]: found argv[1] at 0x7fffffffb5c4: issueexample.py
[SPT]: argv[0] should be at 0x7fffffffb5bd
[SPT]: found argv[0]: python
[SPT]: environ has been copied
0. python python issueexample.py
[SPT]: setup was called more than once!
1. python issueexa python issueexample.py

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