特金特公司;Python:如何给进程命名?
当我运行用Python3创建的TKinter程序时,在我的Linux系统监视器中,我只看到“Python3”作为它的进程名。我怎样才能改变这一点?我想看一个表明我的程序的名字 作为一个解决方案,我只找到了,但我还没有尝试。我想TKinter提供了一个更简单的方法 更新 链接的解决方案(“在linux中更改python脚本的进程名”)确实有效! 示例代码:特金特公司;Python:如何给进程命名?,python,tkinter,process,naming,Python,Tkinter,Process,Naming,当我运行用Python3创建的TKinter程序时,在我的Linux系统监视器中,我只看到“Python3”作为它的进程名。我怎样才能改变这一点?我想看一个表明我的程序的名字 作为一个解决方案,我只找到了,但我还没有尝试。我想TKinter提供了一个更简单的方法 更新 链接的解决方案(“在linux中更改python脚本的进程名”)确实有效! 示例代码: from ctypes import cdll, byref, create_string_buffer procname = b'mypr
from ctypes import cdll, byref, create_string_buffer
procname = b'myprogramname\x00' # Null terminated string
def setProcName(self):
libc = cdll.LoadLibrary('libc.so.6') # Loading a 3rd party library C
buff = create_string_buffer(len(procname)+1) # Note: One larger than the name (man prctl says that)
buff.value = procname # Null terminated string as it should be
libc.prctl(15, byref(buff), 0, 0, 0)
# Refer to "#define" of "/usr/include/linux/prctl.h" for the mysterious value 16 & arg[3..5] are zero as the man page says.
我认为更改进程的名称取决于操作系统,因此我相信您的解决方案是完美的。我不认为特金特会为此提供什么。@toti08:谢谢!我设法解决了!见上面的更新。