Mikhail T.
Mikhail T.

Reputation: 4017

Using PR_SET_NAME from Python

I've been using the following code for a while:

import ctypes
me = ctypes.CDLL(None)
me.prctl(15, "meow", 0, 0, 0)

With Python-2.6 on RHEL6 this works, changing process name to "meow".

With Python-3.7 on RHEL7, however, after going through same code, the process name becomes "m" -- just the first letter of the string.

What's going on?

Upvotes: 1

Views: 250

Answers (1)

Tim Roberts
Tim Roberts

Reputation: 54733

The ctypes prctl is probably expecting 8-bit strings, and in Python 3 you're now passing Unicode. Try me.prctl(15, b"meow", 0, 0, 0).

Upvotes: 3

Related Questions