From c3c5365fcf832764f66d47f2cf0b3170b9651d6c Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Tue, 10 Sep 2019 15:20:21 +0000 Subject: [PATCH] added LargePointer handling in moo_fmt_object_() --- moo/kernel/System.moo | 25 ++++++++++++++++++++----- moo/lib/fmt.c | 5 +++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/moo/kernel/System.moo b/moo/kernel/System.moo index 6d202d5..1550cc2 100644 --- a/moo/kernel/System.moo +++ b/moo/kernel/System.moo @@ -130,7 +130,7 @@ class System(Apex) method(#class) __os_sig_handler: caller { - | os_intr_sem tmp | + | os_intr_sem tmp sh | os_intr_sem := Semaphore new. os_intr_sem signalOnInput: System _getSigfd. @@ -144,9 +144,23 @@ class System(Apex) //TODO: Execute Handler for tmp. System logNl: 'Interrupt dectected - signal no - ' & tmp asString. - if (tmp == 16rFF or tmp == 2) { /* TODO: terminate all processes except gcfin process??? */ goto done }. - }. + // user-defined signal handler is not allowed for 16rFF + if (tmp == 16rFF) { goto done }. + + /* + sh := self.sighandler at: tmp. + if (sh isNil) + {*/ + // the default action for sigint(2) is to terminate all processes. + if (tmp == 2) { goto done }. + /*} + else + { + // invoke a user-defined signal handler if available. + sh value: tmp. + }*/ + }. os_intr_sem wait. }. done: @@ -154,12 +168,12 @@ class System(Apex) ] ensure: [ | pid proc | + + // stop subscribing to signals. os_intr_sem signal. os_intr_sem unsignal. - System logNl: '>>>>Requesting to terminate the caller process ' & (caller id) asString. // the caller must request to terminate all its child processes.. - // TODO: to avoid this, this process must enumerate all proceses and terminate them except this and gcfin process // this disables autonomous process switching only. // TODO: check if the ensure block code can trigger process switching? @@ -182,6 +196,7 @@ class System(Apex) proc := System _findProcessByIdGreaterThan: pid. }. + System logNl: 'Requesting to terminate the caller process of id ' & (caller id) asString. caller terminate. // terminate the startup process. self _enableProcessSwitching. diff --git a/moo/lib/fmt.c b/moo/lib/fmt.c index fc927a4..d3c4db9 100644 --- a/moo/lib/fmt.c +++ b/moo/lib/fmt.c @@ -1429,6 +1429,11 @@ int moo_fmt_object_ (moo_fmtout_t* fmtout, moo_oop_t oop) if (!moo_numtostr(moo, oop, 10 | MOO_NUMTOSTR_NONEWOBJ)) return -1; if (moo_bfmt_out(fmtout, "%.*js", moo->inttostr.xbuf.len, moo->inttostr.xbuf.ptr) <= -1) return -1; } + else if (c == moo->_large_pointer) + { + if (moo_ptrtooow(moo, oop, &i) <= -1) return -1; + if (moo_bfmt_out(fmtout, "#\\p%zX", i) <= -1) return -1; + } else if (MOO_OBJ_GET_FLAGS_TYPE(oop) == MOO_OBJ_TYPE_CHAR) { moo_ooch_t ch;