Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wimglenn opened this issue Aug 26, 2024 · 0 comments
Open

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

wimglenn opened this issue Aug 26, 2024 · 0 comments

Comments

@wimglenn
Copy link

wimglenn commented Aug 26, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant