This is a port of https://golang.org/cl/18150 to the gccgo runtime.
The previous behaviour of installing the signal handlers in a separate
thread meant that Go initialization raced with non-Go initialization if
the non-Go initialization also wanted to install signal handlers. Make
installing signal handlers synchronous so that the process-wide behavior
is predictable.
Reviewed-on: https://go-review.googlesource.com/19494
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233393
138bc75d-0d04-0410-961f-
82ee72b054a4
-28a9dfbc3cda0bf7fd4f3fb1506c547f6cdf41a5
+22278c6e8ce3982b09111183bc6addf0184bef1f
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
struct args *a;
pthread_t tid;
+ runtime_isarchive = true;
+
+ runtime_initsig(true);
+
a = (struct args *) malloc (sizeof *a);
if (a == NULL)
die ("malloc", errno);
{
struct args *a = (struct args *) arg;
- runtime_isarchive = true;
-
if (runtime_isstarted)
return NULL;
runtime_isstarted = true;
runtime_newextram();
runtime_needextram = 0;
}
- runtime_initsig();
+ runtime_initsig(false);
}
if(m->mstartfn)
String runtime_gostring(const byte*);
String runtime_gostringnocopy(const byte*);
void runtime_schedinit(void);
-void runtime_initsig(void);
+void runtime_initsig(bool);
void runtime_sigenable(uint32 sig);
void runtime_sigdisable(uint32 sig);
void runtime_sigignore(uint32 sig);
extern SigTab runtime_sigtab[];
void
-runtime_initsig(void)
+runtime_initsig(bool preinit)
{
int32 i;
SigTab *t;
+ // For c-archive/c-shared this is called by go-libmain.c with
+ // preinit == true.
+ if(runtime_isarchive && !preinit)
+ return;
+
// First call: basic setup.
for(i = 0; runtime_sigtab[i].sig != -1; i++) {
t = &runtime_sigtab[i];
}
}
+ if(runtime_isarchive && (t->flags&SigPanic) == 0)
+ continue;
+
t->flags |= SigHandling;
runtime_setsig(i, runtime_sighandler, true);
}