Skip to content

Commit 807605d

Browse files
Only catch all signals if os/signal package imported.
Fixes #776. R=rsc CC=golang-dev https://golang.org/cl/1745041
1 parent d4384ff commit 807605d

File tree

13 files changed

+27
-12
lines changed

13 files changed

+27
-12
lines changed

Diff for: src/pkg/runtime/darwin/386/signal.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ signalstack(byte *p, int32 n)
129129
}
130130

131131
void
132-
initsig(void)
132+
initsig(int32 queue)
133133
{
134134
int32 i;
135135
static Sigaction sa;
@@ -141,6 +141,8 @@ initsig(void)
141141
sa.sa_tramp = sigtramp; // sigtramp's job is to call into real handler
142142
for(i = 0; i<NSIG; i++) {
143143
if(sigtab[i].flags) {
144+
if((sigtab[i].flags & SigQueue) != queue)
145+
continue;
144146
if(sigtab[i].flags & (SigCatch | SigQueue)) {
145147
sa.__sigaction_u.__sa_sigaction = sighandler;
146148
} else {

Diff for: src/pkg/runtime/darwin/amd64/signal.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ signalstack(byte *p, int32 n)
138138
}
139139

140140
void
141-
initsig(void)
141+
initsig(int32 queue)
142142
{
143143
int32 i;
144144
static Sigaction sa;
@@ -150,6 +150,8 @@ initsig(void)
150150
sa.sa_tramp = sigtramp; // sigtramp's job is to call into real handler
151151
for(i = 0; i<NSIG; i++) {
152152
if(sigtab[i].flags) {
153+
if((sigtab[i].flags & SigQueue) != queue)
154+
continue;
153155
if(sigtab[i].flags & (SigCatch | SigQueue)) {
154156
sa.__sigaction_u.__sa_sigaction = sighandler;
155157
} else {

Diff for: src/pkg/runtime/freebsd/386/signal.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ signalstack(byte *p, int32 n)
124124
}
125125

126126
void
127-
initsig(void)
127+
initsig(int32 queue)
128128
{
129129
static Sigaction sa;
130130

@@ -136,6 +136,8 @@ initsig(void)
136136

137137
for(i = 0; i < NSIG; i++) {
138138
if(sigtab[i].flags) {
139+
if((sigtab[i].flags & SigQueue) != queue)
140+
continue;
139141
if(sigtab[i].flags & (SigCatch | SigQueue))
140142
sa.__sigaction_u.__sa_sigaction = (void*) sigtramp;
141143
else

Diff for: src/pkg/runtime/freebsd/amd64/signal.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ signalstack(byte *p, int32 n)
132132
}
133133

134134
void
135-
initsig(void)
135+
initsig(int32 queue)
136136
{
137137
static Sigaction sa;
138138

@@ -144,6 +144,8 @@ initsig(void)
144144

145145
for(i = 0; i < NSIG; i++) {
146146
if(sigtab[i].flags) {
147+
if((sigtab[i].flags & SigQueue) != queue)
148+
continue;
147149
if(sigtab[i].flags & (SigCatch | SigQueue))
148150
sa.__sigaction_u.__sa_sigaction = (void*) sigtramp;
149151
else

Diff for: src/pkg/runtime/linux/386/signal.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ signalstack(byte *p, int32 n)
116116
}
117117

118118
void
119-
initsig(void)
119+
initsig(int32 queue)
120120
{
121121
static Sigaction sa;
122122

@@ -128,6 +128,8 @@ initsig(void)
128128
sa.sa_restorer = (void*)sigreturn;
129129
for(i = 0; i<NSIG; i++) {
130130
if(sigtab[i].flags) {
131+
if((sigtab[i].flags & SigQueue) != queue)
132+
continue;
131133
if(sigtab[i].flags & (SigCatch | SigQueue))
132134
sa.k_sa_handler = (void*)sigtramp;
133135
else

Diff for: src/pkg/runtime/linux/amd64/signal.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ signalstack(byte *p, int32 n)
126126
}
127127

128128
void
129-
initsig(void)
129+
initsig(int32 queue)
130130
{
131131
static Sigaction sa;
132132

@@ -138,6 +138,8 @@ initsig(void)
138138
sa.sa_restorer = (void*)sigreturn;
139139
for(i = 0; i<NSIG; i++) {
140140
if(sigtab[i].flags) {
141+
if((sigtab[i].flags & SigQueue) != queue)
142+
continue;
141143
if(sigtab[i].flags & (SigCatch | SigQueue))
142144
sa.sa_handler = (void*)sigtramp;
143145
else

Diff for: src/pkg/runtime/linux/arm/signal.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ signalstack(byte *p, int32 n)
120120
}
121121

122122
void
123-
initsig(void)
123+
initsig(int32 queue)
124124
{
125125
static Sigaction sa;
126126

@@ -133,6 +133,8 @@ initsig(void)
133133
sa.sa_restorer = (void*)sigreturn;
134134
for(i = 0; i<NSIG; i++) {
135135
if(sigtab[i].flags) {
136+
if((sigtab[i].flags & SigQueue) != queue)
137+
continue;
136138
if(sigtab[i].flags & (SigCatch | SigQueue))
137139
sa.sa_handler = (void*)sigtramp;
138140
else

Diff for: src/pkg/runtime/nacl/386/signal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "os.h"
99

1010
void
11-
initsig(void)
11+
initsig(int32 queue)
1212
{
1313
}
1414

Diff for: src/pkg/runtime/runtime.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ check(void)
278278
if(z != 4)
279279
throw("cas4");
280280

281-
initsig();
281+
initsig(0);
282282
}
283283

284284
/*

Diff for: src/pkg/runtime/runtime.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ String catstring(String, String);
389389
String gostring(byte*);
390390
String gostringnocopy(byte*);
391391
String gostringw(uint16*);
392-
void initsig(void);
392+
void initsig(int32);
393393
int32 gotraceback(void);
394394
void traceback(uint8 *pc, uint8 *sp, uint8 *lr, G* gp);
395395
void tracebackothers(G*);

Diff for: src/pkg/runtime/sigqueue.goc

+1
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,6 @@ func Signame(sig int32) (name String) {
9494
}
9595

9696
func Siginit() {
97+
initsig(SigQueue);
9798
sig.inuse = true; // enable reception of signals; cannot disable
9899
}

Diff for: src/pkg/runtime/tiny/thread.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ osinit(void)
1717
}
1818

1919
void
20-
initsig(void)
20+
initsig(int32 queue)
2121
{
2222
}
2323

Diff for: src/pkg/runtime/windows/386/signal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
void
6-
initsig(void)
6+
initsig(int32 queue)
77
{
88
}

0 commit comments

Comments
 (0)