From 0ef4dea9441ea53f12040a2e59699b93f1e3913d Mon Sep 17 00:00:00 2001 From: Dominik Vogt Date: Mon, 31 Aug 2015 16:21:28 +0100 Subject: [PATCH] libgo/runtime: S/390: Workaround for broken setcontext in Glibc. In Glibc versions before 2.22, the setcontext() function screws up the signal mask. See commit: 2e807f29595eb5b1e5d0decc6e356a3562ecc58e (https://ibm.biz/BdXwPB) One symptom of this bug is that Docker processes start with blocked signals and e.g. SIGINT is not delivered. This patch works around the Glibc bug in Gccgo at the cost of an additional syscall for each invocation of setcontext(). --- libgo/runtime/proc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index babad01..c6cafa6 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -21,6 +21,17 @@ #include "go-type.h" #include "go-defer.h" +#ifdef __s390__ +// This is a workaround for older Glibc versions where setcontext screwed up the +// signal mask. +# define setcontext(UCP) \ + __extension__ ({ \ + /* Note: On S/390, setcontext never fails. */ \ + sigprocmask(SIG_SETMASK, &(UCP)->uc_sigmask, 0); \ + setcontext(UCP); \ + }) +#endif + #ifdef USING_SPLIT_STACK /* FIXME: These are not declared anywhere. */ -- 2.3.0