From 6f8da9534efd4b3833a77a10bff9d009a84dcf80 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 21 Jun 2011 15:10:23 +0200 Subject: =?UTF-8?q?=C3=84nderung:=20=20=20=20=20=20=20=201564:40817b13d8b3?= =?UTF-8?q?=20Zweig:=20=20=20=20=20=20=20=20=20=20=20dev=20Marke:=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20tip=20Nutzer:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20Cptn=5FSandwich=20Datum:=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?Tue=20Jun=2021=2014:02:50=202011=20+0200=20Zusammenfassung:=20u?= =?UTF-8?q?se=20process=20names=20on=20linux=20instead=20of=20"python"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/lib/rename_process.py | 21 +++++++++++++++++++++ pyLoadCli.py | 2 ++ pyLoadCore.py | 4 ++++ pyLoadGui.py | 3 +++ 4 files changed, 30 insertions(+) create mode 100644 module/lib/rename_process.py diff --git a/module/lib/rename_process.py b/module/lib/rename_process.py new file mode 100644 index 000000000..2aa270171 --- /dev/null +++ b/module/lib/rename_process.py @@ -0,0 +1,21 @@ +import sys +import os.path + + +def RenameProcess(new_name): + """ Renames the process calling the function to the given name. """ + if sys.platform != 'linux2': + print 'Unsupported platform' + return False + try: + import ctypes + is_64 = os.path.exists('/lib64/libc.so.6') + if is_64: + libc = ctypes.CDLL('/lib64/libc.so.6') + else: + libc = ctypes.CDLL('/lib/libc.so.6') + libc.prctl(15, new_name, 0, 0, 0) + return True + except: + print "rename failed" + return False diff --git a/pyLoadCli.py b/pyLoadCli.py index fd5bfbc1c..92d382db1 100644 --- a/pyLoadCli.py +++ b/pyLoadCli.py @@ -42,6 +42,7 @@ from module.utils import formatSize, decode import ConfigParser from module.remote.thriftbackend.ThriftClient import ThriftClient, NoConnection, NoSSL, WrongLogin, ConnectionClosed from module.lib.Getch import Getch +from module.lib.rename_process import RenameProcess class Cli: def __init__(self, client, command): @@ -427,6 +428,7 @@ def writeConfig(opts): print _("Couldn't write user config file") if __name__ == "__main__": + RenameProcess('pyLoadCli') config = {"addr": "127.0.0.1", "port": "7227", "language": "en"} try: config["language"] = os.environ["LANG"][0:2] diff --git a/pyLoadCore.py b/pyLoadCore.py index cc77ac88e..5197e4a9a 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -56,6 +56,8 @@ from module.remote.RemoteManager import RemoteManager from module.database import DatabaseBackend from module.database import FileHandler +from module.lib.rename_process import RenameProcess + from module.utils import freeSpace, formatSize, compare_time from codecs import getwriter @@ -914,6 +916,8 @@ def deamon(): # And so it begins... if __name__ == "__main__": + #change name to 'pyLoadCore' + RenameProcess('pyLoadCore') if "--daemon" in sys.argv: deamon() diff --git a/pyLoadGui.py b/pyLoadGui.py index 6935c502e..d5c20bb83 100755 --- a/pyLoadGui.py +++ b/pyLoadGui.py @@ -45,6 +45,8 @@ from module.gui.Collector import * from module.gui.XMLParser import * from module.gui.CoreConfigParser import ConfigParser +from module.lib.rename_process import RenameProcess + from module.remote.thriftbackend.thriftgen.pyload.ttypes import * try: @@ -778,6 +780,7 @@ class Notification(QObject): self.tray.showMessage("pyload", body) if __name__ == "__main__": + RenameProcess('pyLoadGui') app = main() app.loop() -- cgit v1.2.3