I have some python script name abc.py, but when I execute it, I want to run with some different name, say "def".
Is it possible in python without installing any additional module (procname)?
I have some python script name abc.py, but when I execute it, I want to run with some different name, say "def".
Is it possible in python without installing any additional module (procname)?
You can use pure ctypes calls:
import ctypes
lib = ctypes.cdll.LoadLibrary(None)
prctl = lib.prctl
prctl.restype = ctypes.c_int
prctl.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_ulong,
                  ctypes.c_ulong, ctypes.c_ulong]
def set_proctitle(new_title):
    result = prctl(15, new_title, 0, 0, 0)
    if result != 0:
        raise OSError("prctl result: %d" % result)
Compare: