From 0342a24e2db0a29bf9f7de8f66a2b0ac92387845 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Tue, 25 Aug 2009 15:40:23 +0000 Subject: [PATCH] Sugar crashing when saving a journal entry upon closing an activity #1123 --- src/sugar/activity/activityfactory.py | 38 ++++++++++++++------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/sugar/activity/activityfactory.py b/src/sugar/activity/activityfactory.py index d71e7def..40733b80 100644 --- a/src/sugar/activity/activityfactory.py +++ b/src/sugar/activity/activityfactory.py @@ -269,26 +269,9 @@ class ActivityCreationHandler(gobject.GObject): stderr=log_file.fileno()) gobject.child_watch_add(child.pid, - self.__child_watch_cb, + __child_watch_cb, (environment_dir, log_file)) - def __child_watch_cb(self, pid, condition, user_data): - environment_dir, log_file = user_data - if environment_dir is not None: - subprocess.call(['/bin/rm', '-rf', environment_dir]) - try: - log_file.write('Activity died: pid %s condition %s data %s\n' % - (pid, condition, user_data)) - finally: - log_file.close() - - # try to reap zombies in case SIGCHLD has not been set to SIG_IGN - try: - os.waitpid(pid, 0) - except OSError: - # SIGCHLD = SIG_IGN, no zombies - pass - def _no_reply_handler(self, *args): pass @@ -342,3 +325,22 @@ def create_with_object_id(bundle, object_id): """Create a new activity and pass the object id as handle.""" activity_handle = ActivityHandle(object_id=object_id) return ActivityCreationHandler(bundle, activity_handle) + +# FIXME we use standalone method here instead of ActivityCreationHandler's +# member to have workaround code, see #1123 +def __child_watch_cb(pid, condition, user_data): + environment_dir, log_file = user_data + if environment_dir is not None: + subprocess.call(['/bin/rm', '-rf', environment_dir]) + try: + log_file.write('Activity died: pid %s condition %s data %s\n' % + (pid, condition, user_data)) + finally: + log_file.close() + + # try to reap zombies in case SIGCHLD has not been set to SIG_IGN + try: + os.waitpid(pid, 0) + except OSError: + # SIGCHLD = SIG_IGN, no zombies + pass