Ticket #1123: sugar-1123.patch

File sugar-1123.patch, 2.3 KB (added by alsroot, 15 years ago)

moving child_watch_add's callback to standalone method fixes this issue(looks like ActivityCreationHandler object is died in place of invoking child_watch_add's callback)

  • src/sugar/activity/activityfactory.py

    From 1de6d19ff4e7fdf6d2b68ba8aaa60d1fd4245d7c Mon Sep 17 00:00:00 2001
    From: Aleksey Lim <alsroot@member.fsf.org>
    Date: Tue, 25 Aug 2009 13:06:25 +0000
    Subject: Sugar crashing when saving a journal entry upon closing an activity #1123
    
    ---
     src/sugar/activity/activityfactory.py |   36 ++++++++++++++++----------------
     1 files changed, 18 insertions(+), 18 deletions(-)
    
    diff --git a/src/sugar/activity/activityfactory.py b/src/sugar/activity/activityfactory.py
    index dcd840f..9da029a 100644
    a b class ActivityCreationHandler(gobject.GObject): 
    276276            stderr=log_file.fileno())
    277277
    278278        gobject.child_watch_add(child.pid,
    279                                 self.__child_watch_cb,
     279                                __child_watch_cb,
    280280                                (environment_dir, log_file))
    281281
    282     def __child_watch_cb(self, pid, condition, user_data):
    283         environment_dir, log_file = user_data
    284         if environment_dir is not None:
    285             subprocess.call(['/bin/rm', '-rf', environment_dir])
    286         try:
    287             log_file.write('Activity died: pid %s condition %s data %s\n' %
    288                 (pid, condition, user_data))
    289         finally:
    290             log_file.close()
    291 
    292         # try to reap zombies in case SIGCHLD has not been set to SIG_IGN
    293         try:
    294             os.waitpid(pid, 0)
    295         except OSError:
    296             # SIGCHLD = SIG_IGN, no zombies
    297             pass
    298 
    299282    def _no_reply_handler(self, *args):
    300283        pass
    301284
    def create_with_object_id(bundle, object_id): 
    349332    """Create a new activity and pass the object id as handle."""
    350333    activity_handle = ActivityHandle(object_id=object_id)
    351334    return ActivityCreationHandler(bundle, activity_handle)
     335
     336def __child_watch_cb(pid, condition, user_data):
     337    environment_dir, log_file = user_data
     338    if environment_dir is not None:
     339        subprocess.call(['/bin/rm', '-rf', environment_dir])
     340    try:
     341        log_file.write('Activity died: pid %s condition %s data %s\n' %
     342            (pid, condition, user_data))
     343    finally:
     344        log_file.close()
     345
     346    # try to reap zombies in case SIGCHLD has not been set to SIG_IGN
     347    try:
     348        os.waitpid(pid, 0)
     349    except OSError:
     350        # SIGCHLD = SIG_IGN, no zombies
     351        pass