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?
Advertisement
Answer
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)
.