LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "defs_GOOS_GOARCH.h" | 6 #include "defs_GOOS_GOARCH.h" |
7 #include "signals_GOOS.h" | 7 #include "signals_GOOS.h" |
8 #include "os_GOOS.h" | 8 #include "os_GOOS.h" |
9 | 9 |
10 void | 10 void |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void | 128 void |
129 runtime·setsig(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart) | 129 runtime·setsig(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart) |
130 { | 130 { |
131 Sigaction sa; | 131 Sigaction sa; |
132 | 132 |
133 runtime·memclr((byte*)&sa, sizeof sa); | 133 runtime·memclr((byte*)&sa, sizeof sa); |
134 sa.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_RESTORER; | 134 sa.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_RESTORER; |
135 if(restart) | 135 if(restart) |
136 sa.sa_flags |= SA_RESTART; | 136 sa.sa_flags |= SA_RESTART; |
137 sa.sa_mask = ~0ULL; | 137 sa.sa_mask = ~0ULL; |
138 » // Linux manpage says "sa_restart element is obsolete and | 138 » // TODO(adonovan): Linux manpage says "sa_restorer element is |
139 » // should not be used". | 139 » // obsolete and should not be used". Avoid it here, and test. |
140 sa.sa_restorer = (void*)runtime·sigreturn; | 140 sa.sa_restorer = (void*)runtime·sigreturn; |
141 if(fn == runtime·sighandler) | 141 if(fn == runtime·sighandler) |
142 fn = (void*)runtime·sigtramp; | 142 fn = (void*)runtime·sigtramp; |
143 sa.sa_handler = fn; | 143 sa.sa_handler = fn; |
144 if(runtime·rt_sigaction(i, &sa, nil, sizeof(sa.sa_mask)) != 0) | 144 if(runtime·rt_sigaction(i, &sa, nil, sizeof(sa.sa_mask)) != 0) |
145 runtime·throw("rt_sigaction failure"); | 145 runtime·throw("rt_sigaction failure"); |
146 } | 146 } |
LEFT | RIGHT |