summaryrefslogtreecommitdiff
path: root/libc-parts/_exit.c
diff options
context:
space:
mode:
authorneal <neal>2008-02-11 09:47:46 +0000
committerneal <neal>2008-02-11 09:47:46 +0000
commitd74240e3cf99a32dadade7e414ce5aabee6f1982 (patch)
tree5e94ff3345aae9f879ffea1bdc2ae8dc7d82731f /libc-parts/_exit.c
parent8790e4b62b108a1911018aa25cb01ef5f9fd51ec (diff)
2008-02-11 Neal H. Walfield <neal@gnu.org>
* _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.
Diffstat (limited to 'libc-parts/_exit.c')
-rw-r--r--libc-parts/_exit.c44
1 files changed, 32 insertions, 12 deletions
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.");