Commit 3d8ebefb authored by David Symonds's avatar David Symonds

runtime: Permit default behaviour of SIGTSTP, SIGTTIN, SIGTTOU.

Fixes #3037.

R=rsc, minux.ma, r, rsc
CC=golang-dev
https://golang.org/cl/5674072
parent efb28b2a
...@@ -271,6 +271,7 @@ enum ...@@ -271,6 +271,7 @@ enum
SigKill = 1<<1, // if signal.Notify doesn't take it, exit quietly SigKill = 1<<1, // if signal.Notify doesn't take it, exit quietly
SigThrow = 1<<2, // if signal.Notify doesn't take it, exit loudly SigThrow = 1<<2, // if signal.Notify doesn't take it, exit loudly
SigPanic = 1<<3, // if the signal is from the kernel, panic SigPanic = 1<<3, // if the signal is from the kernel, panic
SigDefault = 1<<4, // if the signal isn't explicitly requested, don't monitor it
}; };
// NOTE(rsc): keep in sync with extern.go:/type.Func. // NOTE(rsc): keep in sync with extern.go:/type.Func.
...@@ -501,6 +502,7 @@ Slice runtime·gobytes(byte*, int32); ...@@ -501,6 +502,7 @@ Slice runtime·gobytes(byte*, int32);
String runtime·gostringnocopy(byte*); String runtime·gostringnocopy(byte*);
String runtime·gostringw(uint16*); String runtime·gostringw(uint16*);
void runtime·initsig(void); void runtime·initsig(void);
void runtime·sigenable(uint32 sig);
int32 runtime·gotraceback(void); int32 runtime·gotraceback(void);
void runtime·goroutineheader(G*); void runtime·goroutineheader(G*);
void runtime·traceback(uint8 *pc, uint8 *sp, uint8 *lr, G* gp); void runtime·traceback(uint8 *pc, uint8 *sp, uint8 *lr, G* gp);
......
...@@ -10,6 +10,11 @@ runtime·signame(int32) ...@@ -10,6 +10,11 @@ runtime·signame(int32)
return runtime·emptystring; return runtime·emptystring;
} }
void
runtime·sigenable(uint32 sig)
{
}
void void
runtime·resetcpuprofiler(int32 hz) runtime·resetcpuprofiler(int32 hz)
{ {
......
...@@ -27,9 +27,27 @@ runtime·initsig(void) ...@@ -27,9 +27,27 @@ runtime·initsig(void)
// First call: basic setup. // First call: basic setup.
for(i = 0; i<NSIG; i++) { for(i = 0; i<NSIG; i++) {
t = &runtime·sigtab[i]; t = &runtime·sigtab[i];
if(t->flags == 0) if((t->flags == 0) || (t->flags & SigDefault))
continue; continue;
runtime·setsig(i, runtime·sighandler, 1); runtime·setsig(i, runtime·sighandler, true);
}
}
void
runtime·sigenable(uint32 sig)
{
int32 i;
SigTab *t;
for(i = 0; i<NSIG; i++) {
// ~0 means all signals.
if(~sig == 0 || i == sig) {
t = &runtime·sigtab[i];
if(t->flags & SigDefault) {
runtime·setsig(i, runtime·sighandler, true);
t->flags &= ~SigDefault; // make this idempotent
}
}
} }
} }
......
...@@ -80,6 +80,11 @@ runtime·sighandler(ExceptionRecord *info, Context *r, G *gp) ...@@ -80,6 +80,11 @@ runtime·sighandler(ExceptionRecord *info, Context *r, G *gp)
return 0; return 0;
} }
void
runtime·sigenable(uint32 sig)
{
}
void void
runtime·dosigprof(Context *r, G *gp) runtime·dosigprof(Context *r, G *gp)
{ {
......
...@@ -87,6 +87,11 @@ runtime·sighandler(ExceptionRecord *info, Context *r, G *gp) ...@@ -87,6 +87,11 @@ runtime·sighandler(ExceptionRecord *info, Context *r, G *gp)
return 0; return 0;
} }
void
runtime·sigenable(uint32 sig)
{
}
void void
runtime·dosigprof(Context *r, G *gp) runtime·dosigprof(Context *r, G *gp)
{ {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define K SigKill #define K SigKill
#define T SigThrow #define T SigThrow
#define P SigPanic #define P SigPanic
#define D SigDefault
SigTab runtime·sigtab[] = { SigTab runtime·sigtab[] = {
/* 0 */ 0, "SIGNONE: no trap", /* 0 */ 0, "SIGNONE: no trap",
...@@ -26,11 +27,11 @@ SigTab runtime·sigtab[] = { ...@@ -26,11 +27,11 @@ SigTab runtime·sigtab[] = {
/* 15 */ N+K, "SIGTERM: termination", /* 15 */ N+K, "SIGTERM: termination",
/* 16 */ N, "SIGURG: urgent condition on socket", /* 16 */ N, "SIGURG: urgent condition on socket",
/* 17 */ 0, "SIGSTOP: stop", /* 17 */ 0, "SIGSTOP: stop",
/* 18 */ N, "SIGTSTP: keyboard stop", /* 18 */ N+D, "SIGTSTP: keyboard stop",
/* 19 */ 0, "SIGCONT: continue after stop", /* 19 */ 0, "SIGCONT: continue after stop",
/* 20 */ N, "SIGCHLD: child status has changed", /* 20 */ N, "SIGCHLD: child status has changed",
/* 21 */ N, "SIGTTIN: background read from tty", /* 21 */ N+D, "SIGTTIN: background read from tty",
/* 22 */ N, "SIGTTOU: background write to tty", /* 22 */ N+D, "SIGTTOU: background write to tty",
/* 23 */ N, "SIGIO: i/o now possible", /* 23 */ N, "SIGIO: i/o now possible",
/* 24 */ N, "SIGXCPU: cpu limit exceeded", /* 24 */ N, "SIGXCPU: cpu limit exceeded",
/* 25 */ N, "SIGXFSZ: file size limit exceeded", /* 25 */ N, "SIGXFSZ: file size limit exceeded",
...@@ -46,3 +47,4 @@ SigTab runtime·sigtab[] = { ...@@ -46,3 +47,4 @@ SigTab runtime·sigtab[] = {
#undef K #undef K
#undef T #undef T
#undef P #undef P
#undef D
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define K SigKill #define K SigKill
#define T SigThrow #define T SigThrow
#define P SigPanic #define P SigPanic
#define D SigDefault
SigTab runtime·sigtab[] = { SigTab runtime·sigtab[] = {
/* 0 */ 0, "SIGNONE: no trap", /* 0 */ 0, "SIGNONE: no trap",
...@@ -26,11 +27,11 @@ SigTab runtime·sigtab[] = { ...@@ -26,11 +27,11 @@ SigTab runtime·sigtab[] = {
/* 15 */ N+K, "SIGTERM: termination", /* 15 */ N+K, "SIGTERM: termination",
/* 16 */ N, "SIGURG: urgent condition on socket", /* 16 */ N, "SIGURG: urgent condition on socket",
/* 17 */ 0, "SIGSTOP: stop", /* 17 */ 0, "SIGSTOP: stop",
/* 18 */ N, "SIGTSTP: keyboard stop", /* 18 */ N+D, "SIGTSTP: keyboard stop",
/* 19 */ 0, "SIGCONT: continue after stop", /* 19 */ 0, "SIGCONT: continue after stop",
/* 20 */ N, "SIGCHLD: child status has changed", /* 20 */ N, "SIGCHLD: child status has changed",
/* 21 */ N, "SIGTTIN: background read from tty", /* 21 */ N+D, "SIGTTIN: background read from tty",
/* 22 */ N, "SIGTTOU: background write to tty", /* 22 */ N+D, "SIGTTOU: background write to tty",
/* 23 */ N, "SIGIO: i/o now possible", /* 23 */ N, "SIGIO: i/o now possible",
/* 24 */ N, "SIGXCPU: cpu limit exceeded", /* 24 */ N, "SIGXCPU: cpu limit exceeded",
/* 25 */ N, "SIGXFSZ: file size limit exceeded", /* 25 */ N, "SIGXFSZ: file size limit exceeded",
...@@ -47,3 +48,4 @@ SigTab runtime·sigtab[] = { ...@@ -47,3 +48,4 @@ SigTab runtime·sigtab[] = {
#undef K #undef K
#undef T #undef T
#undef P #undef P
#undef D
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define K SigKill #define K SigKill
#define T SigThrow #define T SigThrow
#define P SigPanic #define P SigPanic
#define D SigDefault
SigTab runtime·sigtab[] = { SigTab runtime·sigtab[] = {
/* 0 */ 0, "SIGNONE: no trap", /* 0 */ 0, "SIGNONE: no trap",
...@@ -28,9 +29,9 @@ SigTab runtime·sigtab[] = { ...@@ -28,9 +29,9 @@ SigTab runtime·sigtab[] = {
/* 17 */ N, "SIGCHLD: child status has changed", /* 17 */ N, "SIGCHLD: child status has changed",
/* 18 */ 0, "SIGCONT: continue", /* 18 */ 0, "SIGCONT: continue",
/* 19 */ 0, "SIGSTOP: stop, unblockable", /* 19 */ 0, "SIGSTOP: stop, unblockable",
/* 20 */ N, "SIGTSTP: keyboard stop", /* 20 */ N+D, "SIGTSTP: keyboard stop",
/* 21 */ N, "SIGTTIN: background read from tty", /* 21 */ N+D, "SIGTTIN: background read from tty",
/* 22 */ N, "SIGTTOU: background write to tty", /* 22 */ N+D, "SIGTTOU: background write to tty",
/* 23 */ N, "SIGURG: urgent condition on socket", /* 23 */ N, "SIGURG: urgent condition on socket",
/* 24 */ N, "SIGXCPU: cpu limit exceeded", /* 24 */ N, "SIGXCPU: cpu limit exceeded",
/* 25 */ N, "SIGXFSZ: file size limit exceeded", /* 25 */ N, "SIGXFSZ: file size limit exceeded",
...@@ -79,3 +80,4 @@ SigTab runtime·sigtab[] = { ...@@ -79,3 +80,4 @@ SigTab runtime·sigtab[] = {
#undef K #undef K
#undef T #undef T
#undef P #undef P
#undef D
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define K SigKill #define K SigKill
#define T SigThrow #define T SigThrow
#define P SigPanic #define P SigPanic
#define D SigDefault
SigTab runtime·sigtab[] = { SigTab runtime·sigtab[] = {
/* 0 */ 0, "SIGNONE: no trap", /* 0 */ 0, "SIGNONE: no trap",
...@@ -26,11 +27,11 @@ SigTab runtime·sigtab[] = { ...@@ -26,11 +27,11 @@ SigTab runtime·sigtab[] = {
/* 15 */ N+K, "SIGTERM: termination", /* 15 */ N+K, "SIGTERM: termination",
/* 16 */ N, "SIGURG: urgent condition on socket", /* 16 */ N, "SIGURG: urgent condition on socket",
/* 17 */ 0, "SIGSTOP: stop", /* 17 */ 0, "SIGSTOP: stop",
/* 18 */ N, "SIGTSTP: keyboard stop", /* 18 */ N+D, "SIGTSTP: keyboard stop",
/* 19 */ 0, "SIGCONT: continue after stop", /* 19 */ 0, "SIGCONT: continue after stop",
/* 20 */ N, "SIGCHLD: child status has changed", /* 20 */ N, "SIGCHLD: child status has changed",
/* 21 */ N, "SIGTTIN: background read from tty", /* 21 */ N+D, "SIGTTIN: background read from tty",
/* 22 */ N, "SIGTTOU: background write to tty", /* 22 */ N+D, "SIGTTOU: background write to tty",
/* 23 */ N, "SIGIO: i/o now possible", /* 23 */ N, "SIGIO: i/o now possible",
/* 24 */ N, "SIGXCPU: cpu limit exceeded", /* 24 */ N, "SIGXCPU: cpu limit exceeded",
/* 25 */ N, "SIGXFSZ: file size limit exceeded", /* 25 */ N, "SIGXFSZ: file size limit exceeded",
...@@ -47,3 +48,4 @@ SigTab runtime·sigtab[] = { ...@@ -47,3 +48,4 @@ SigTab runtime·sigtab[] = {
#undef K #undef K
#undef T #undef T
#undef P #undef P
#undef D
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define K SigKill #define K SigKill
#define T SigThrow #define T SigThrow
#define P SigPanic #define P SigPanic
#define D SigDefault
SigTab runtime·sigtab[] = { SigTab runtime·sigtab[] = {
/* 0 */ 0, "SIGNONE: no trap", /* 0 */ 0, "SIGNONE: no trap",
...@@ -26,11 +27,11 @@ SigTab runtime·sigtab[] = { ...@@ -26,11 +27,11 @@ SigTab runtime·sigtab[] = {
/* 15 */ N+K, "SIGTERM: termination", /* 15 */ N+K, "SIGTERM: termination",
/* 16 */ N, "SIGURG: urgent condition on socket", /* 16 */ N, "SIGURG: urgent condition on socket",
/* 17 */ 0, "SIGSTOP: stop", /* 17 */ 0, "SIGSTOP: stop",
/* 18 */ N, "SIGTSTP: keyboard stop", /* 18 */ N+D, "SIGTSTP: keyboard stop",
/* 19 */ 0, "SIGCONT: continue after stop", /* 19 */ 0, "SIGCONT: continue after stop",
/* 20 */ N, "SIGCHLD: child status has changed", /* 20 */ N, "SIGCHLD: child status has changed",
/* 21 */ N, "SIGTTIN: background read from tty", /* 21 */ N+D, "SIGTTIN: background read from tty",
/* 22 */ N, "SIGTTOU: background write to tty", /* 22 */ N+D, "SIGTTOU: background write to tty",
/* 23 */ N, "SIGIO: i/o now possible", /* 23 */ N, "SIGIO: i/o now possible",
/* 24 */ N, "SIGXCPU: cpu limit exceeded", /* 24 */ N, "SIGXCPU: cpu limit exceeded",
/* 25 */ N, "SIGXFSZ: file size limit exceeded", /* 25 */ N, "SIGXFSZ: file size limit exceeded",
...@@ -47,3 +48,4 @@ SigTab runtime·sigtab[] = { ...@@ -47,3 +48,4 @@ SigTab runtime·sigtab[] = {
#undef K #undef K
#undef T #undef T
#undef P #undef P
#undef D
...@@ -140,10 +140,12 @@ func signal_enable(s uint32) { ...@@ -140,10 +140,12 @@ func signal_enable(s uint32) {
// Special case: want everything. // Special case: want everything.
for(i=0; i<nelem(sig.wanted); i++) for(i=0; i<nelem(sig.wanted); i++)
sig.wanted[i] = ~(uint32)0; sig.wanted[i] = ~(uint32)0;
runtime·sigenable(s);
return; return;
} }
if(s >= nelem(sig.wanted)*32) if(s >= nelem(sig.wanted)*32)
return; return;
sig.wanted[s/32] |= 1U<<(s&31); sig.wanted[s/32] |= 1U<<(s&31);
runtime·sigenable(s);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment