From 9cdd9058da2609f0f4f827f0af62666401fe001c Mon Sep 17 00:00:00 2001 From: John (J5) Palmieri Date: Wed, 27 Jun 2007 21:12:32 +0000 Subject: add process title setting to activities * they now will show up as Activity Name in the process list truncated to 15 characters though --- (limited to 'sugar/util.py') diff --git a/sugar/util.py b/sugar/util.py index 8e15e92..7b895be 100644 --- a/sugar/util.py +++ b/sugar/util.py @@ -103,3 +103,25 @@ def write_service(name, bin, path): fileobject = open(dest_filename, 'w') service_cp.write(fileobject) fileobject.close() + +def set_proc_title(title): + """Sets the process title so ps and top show more + descriptive names. This does not modify argv[0] + and only the first 15 characters will be shown. + + title -- the title you wish to change the process + title to + + Returns True on success. We don't raise exceptions + because if something goes wrong here it is not a big + deal as this is intended as a nice thing to have for + debugging + """ + try: + import ctypes + libc = ctypes.CDLL('libc.so.6') + libc.prctl(15, str(title), 0, 0, 0) + + return True + except: + return False -- cgit v0.9.1