diff --git a/gc_boehm.c b/gc_boehm.c index de4b9eb..343b383 100644 --- a/gc_boehm.c +++ b/gc_boehm.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "gc_ops.h" #define I_HIDE_POINTERS #include @@ -454,11 +455,17 @@ void* objc_gc_reallocate_collectable(void *ptr, size_t size, BOOL isScanned) static void init(void) { GC_INIT(); + char *sigNumber; // Dump GC stats on exit - uncomment when debugging. if (getenv("LIBOBJC_DUMP_GC_STATUS_ON_EXIT")) { atexit(GC_dump); } + if ((sigNumber = getenv("LIBOBJC_DUMP_GC_STATUS_ON_SIGNAL"))) + { + int s = sigNumber[0] ? (int)strtol(sigNumber, NULL, 10) : SIGUSR2; + signal(s, (void(*)(int))GC_dump); + } refcounts = refcount_create(4096); GC_clear_roots(); finalize = sel_registerName("finalize");