Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <quinticent@localhost.localdomain>2007-06-27 21:12:32 (GMT)
committer John (J5) Palmieri <quinticent@localhost.localdomain>2007-06-27 21:12:32 (GMT)
commit9cdd9058da2609f0f4f827f0af62666401fe001c (patch)
tree6840143f0fe7793bc84a7a9498e824a394b94b8b /sugar
parent381df084425e8e13783f10190279224bb54b7848 (diff)
add process title setting to activities
* they now will show up as Activity Name <id> in the process list truncated to 15 characters though
Diffstat (limited to 'sugar')
-rw-r--r--sugar/activity/activity.py11
-rw-r--r--sugar/util.py22
2 files changed, 32 insertions, 1 deletions
diff --git a/sugar/activity/activity.py b/sugar/activity/activity.py
index 56b0a1c..0407a8e 100644
--- a/sugar/activity/activity.py
+++ b/sugar/activity/activity.py
@@ -28,7 +28,8 @@ import tempfile
import gtk, gobject
import dbus
-
+
+from sugar import util
from sugar.presence import presenceservice
from sugar.activity.activityservice import ActivityService
from sugar.graphics import units
@@ -199,6 +200,13 @@ class Activity(Window, gtk.Container):
"""
Window.__init__(self)
+ # process titles will only show 15 characters
+ # but they get truncated anyway so if more characters
+ # are supported in the future we will get a better view
+ # of the processes
+ proc_title = "%s <%s>" % (get_bundle_name(), handle.activity_id)
+ util.set_proc_title(proc_title)
+
self.connect('realize', self._realize_cb)
self.connect('delete-event', self._delete_event_cb)
@@ -397,3 +405,4 @@ def get_bundle_path():
"""Return the bundle path for the current process' bundle
"""
return os.environ['SUGAR_BUNDLE_PATH']
+
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