From 13e7b262029c6f9add87c678189eb84da5dde5d7 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Fri, 8 Jan 2021 18:50:34 +0000 Subject: [PATCH] Fix SIGALRM core dump (Solaris patch 230-18229654) This should fix the following Solaris bug: 18229654 ksh93 read not reentrant in alarm context dumps core with the patch taken from: https://github.com/oracle/solaris-userland/blob/master/components/ksh93/patches/230-18229654.patch Unfortunately the link to the details is inaccessible as lists.research.att.com is dead. --- src/cmd/ksh93/bltins/alarm.c | 2 +- src/cmd/ksh93/sh/xec.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/ksh93/bltins/alarm.c b/src/cmd/ksh93/bltins/alarm.c index 5d152cc16..6f0833698 100644 --- a/src/cmd/ksh93/bltins/alarm.c +++ b/src/cmd/ksh93/bltins/alarm.c @@ -134,7 +134,7 @@ static void trap_timeout(void* handle) tp->timeout = 0; tp->flags |= L_FLAG; tp->sh->sigflag[SIGALRM] |= SH_SIGALRM; - if(sh_isstate(SH_TTYWAIT)) + if(sh_isstate(SH_TTYWAIT) && !tp->sh->bltinfun) sh_timetraps(tp->sh); } diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index f34fb5e1b..85844f5be 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -2643,6 +2643,11 @@ int sh_exec(register const Shnode_t *t, int flags) break; } } + if(shp->trapnote&SH_SIGALRM) + { + shp->trapnote &= ~SH_SIGALRM; + sh_timetraps(shp); + } if(shp->trapnote || (shp->exitval && sh_isstate(SH_ERREXIT)) && t && echeck) sh_chktrap(shp);