From d74240e3cf99a32dadade7e414ce5aabee6f1982 Mon Sep 17 00:00:00 2001 From: neal Date: Mon, 11 Feb 2008 09:47:46 +0000 Subject: 2008-02-11 Neal H. Walfield * _exit.c (_exit): Destroy the activity by finding its associated storage and deallocating that. If killing the activity fails, try the same approach with the thread. --- libc-parts/_exit.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'libc-parts/_exit.c') diff --git a/libc-parts/_exit.c b/libc-parts/_exit.c index 74250fc..dda1b49 100644 --- a/libc-parts/_exit.c +++ b/libc-parts/_exit.c @@ -35,18 +35,38 @@ _exit (int ret) #else extern struct hurd_startup_data *__hurd_startup_data; - addr_t folio = addr_chop (__hurd_startup_data->activity, - FOLIO_OBJECTS_LOG2); - int index = addr_extract (__hurd_startup_data->activity, - FOLIO_OBJECTS_LOG2); - - error_t err; - err = rm_folio_object_alloc (ADDR_VOID, folio, index, - cap_void, OBJECT_POLICY_VOID, - (uintptr_t) ret, - ADDR_VOID, ADDR_VOID); - - assert_perror (err); + /* We try to kill the activity and, if that fails, the main + thread. */ + addr_t objs[] = { __hurd_startup_data->activity, + __hurd_startup_data->thread }; + + int o; + for (o = 0; o < sizeof (objs) / sizeof (objs[0]); o ++) + { + int i; + for (i = 0; i < __hurd_startup_data->desc_count; i ++) + { + struct hurd_object_desc *desc = &__hurd_startup_data->descs[i]; + if (ADDR_EQ (desc->object, objs[o])) + { + if (ADDR_IS_VOID (desc->storage)) + /* We don't own the storage and thus can't deallocate + the object. */ + continue; + + addr_t folio = addr_chop (desc->storage, FOLIO_OBJECTS_LOG2); + int index = addr_extract (desc->storage, FOLIO_OBJECTS_LOG2); + + error_t err; + err = rm_folio_object_alloc (ADDR_VOID, folio, index, + cap_void, OBJECT_POLICY_VOID, + (uintptr_t) ret, + ADDR_VOID, ADDR_VOID); + if (err) + debug (0, "deallocating object: %d", err); + } + } + } #endif debug (0, "Failed to die gracefully; doing the ultra-violent."); -- cgit v1.2.3