Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(628)

Issue 3749041: code review 3749041: os/signal: selective signal handling (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 11 months ago by rsc
Modified:
12 years, 9 months ago
Reviewers:
CC:
r, dsymonds, bradfitz, iant, borman, golang-dev
Visibility:
Public.

Description

os/signal: selective signal handling Restore package os/signal, with new API: Notify replaces Incoming, allowing clients to ask for certain signals only. Also, signals go to everyone who asks, not just one client. This could plausibly move into package os now that there are no magic side effects as a result of the import. Update runtime for new API: move common Unix signal handling code into signal_unix.c. (It's so easy to do this now that we don't have to edit Makefiles!) Tested on darwin,linux 386,amd64. Fixes issue 1266.

Patch Set 1 #

Patch Set 2 : diff -r 1f2a839158ce https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 1f2a839158ce https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 1f2a839158ce https://go.googlecode.com/hg/ #

Total comments: 26

Patch Set 5 : diff -r caf7dca9d711 https://go.googlecode.com/hg/ #

Total comments: 51

Patch Set 6 : diff -r cbee2f341f10 https://go.googlecode.com/hg/ #

Patch Set 7 : diff -r 9d7addec2635 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1218 lines, -1268 lines) Patch
M doc/go1.html View 1 2 3 4 5 6 1 chunk +33 lines, -0 lines 0 comments Download
M doc/go1.tmpl View 1 2 3 4 5 6 1 chunk +33 lines, -0 lines 0 comments Download
R src/pkg/exp/signal/signal.go View 1 1 chunk +0 lines, -37 lines 0 comments Download
R src/pkg/exp/signal/signal_test.go View 1 1 chunk +0 lines, -24 lines 0 comments Download
M src/pkg/net/http/cgi/host_test.go View 1 2 2 chunks +2 lines, -1 line 0 comments Download
M src/pkg/os/exec.go View 1 2 3 4 1 chunk +12 lines, -1 line 0 comments Download
M src/pkg/os/exec_posix.go View 1 2 3 4 5 3 chunks +3 lines, -14 lines 0 comments Download
M src/pkg/os/exec_unix.go View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M src/pkg/os/exec_windows.go View 1 2 3 4 5 1 chunk +2 lines, -1 line 0 comments Download
A src/pkg/os/signal/sig.s View 1 1 chunk +16 lines, -0 lines 0 comments Download
A src/pkg/os/signal/signal.go View 1 2 3 4 5 1 chunk +72 lines, -0 lines 0 comments Download
A src/pkg/os/signal/signal_test.go View 1 2 3 4 1 chunk +60 lines, -0 lines 0 comments Download
A src/pkg/os/signal/signal_unix.go View 1 2 3 4 5 1 chunk +38 lines, -0 lines 0 comments Download
M src/pkg/runtime/os_darwin.h View 1 2 3 4 5 2 chunks +5 lines, -0 lines 0 comments Download
M src/pkg/runtime/os_freebsd.h View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M src/pkg/runtime/os_linux.h View 1 2 3 4 5 1 chunk +5 lines, -0 lines 0 comments Download
M src/pkg/runtime/os_netbsd.h View 1 2 3 4 5 1 chunk +5 lines, -0 lines 0 comments Download
M src/pkg/runtime/os_openbsd.h View 1 2 3 4 5 1 chunk +5 lines, -0 lines 0 comments Download
M src/pkg/runtime/runtime.h View 1 2 3 4 5 2 chunks +5 lines, -6 lines 0 comments Download
M src/pkg/runtime/runtime.c View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
R src/pkg/runtime/sig.go View 1 2 3 4 1 chunk +0 lines, -16 lines 0 comments Download
M src/pkg/runtime/signal_darwin_386.c View 1 2 3 4 7 chunks +14 lines, -67 lines 0 comments Download
M src/pkg/runtime/signal_darwin_amd64.c View 1 2 3 4 7 chunks +16 lines, -69 lines 0 comments Download
M src/pkg/runtime/signal_freebsd_386.c View 1 2 3 4 6 chunks +14 lines, -61 lines 0 comments Download
M src/pkg/runtime/signal_freebsd_amd64.c View 1 2 3 4 6 chunks +13 lines, -69 lines 0 comments Download
M src/pkg/runtime/signal_linux_386.c View 1 2 3 4 6 chunks +17 lines, -65 lines 0 comments Download
M src/pkg/runtime/signal_linux_amd64.c View 1 2 3 4 6 chunks +14 lines, -63 lines 0 comments Download
M src/pkg/runtime/signal_linux_arm.c View 1 2 3 4 3 chunks +2 lines, -58 lines 0 comments Download
M src/pkg/runtime/signal_netbsd_386.c View 1 2 3 4 5 chunks +14 lines, -69 lines 0 comments Download
M src/pkg/runtime/signal_netbsd_amd64.c View 1 2 3 4 6 chunks +14 lines, -70 lines 0 comments Download
M src/pkg/runtime/signal_openbsd_386.c View 1 2 3 4 5 chunks +14 lines, -69 lines 0 comments Download
M src/pkg/runtime/signal_openbsd_amd64.c View 1 2 3 4 6 chunks +14 lines, -70 lines 0 comments Download
A src/pkg/runtime/signal_unix.c View 1 2 3 4 5 1 chunk +60 lines, -0 lines 0 comments Download
M src/pkg/runtime/signal_windows_386.c View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/signal_windows_amd64.c View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/signals_darwin.h View 1 2 3 4 1 chunk +35 lines, -38 lines 0 comments Download
M src/pkg/runtime/signals_freebsd.h View 1 2 3 4 1 chunk +40 lines, -43 lines 0 comments Download
M src/pkg/runtime/signals_linux.h View 1 2 3 4 1 chunk +68 lines, -38 lines 0 comments Download
M src/pkg/runtime/signals_netbsd.h View 1 2 3 4 1 chunk +40 lines, -43 lines 0 comments Download
M src/pkg/runtime/signals_openbsd.h View 1 2 3 4 1 chunk +40 lines, -43 lines 0 comments Download
M src/pkg/runtime/sigqueue.goc View 1 2 3 4 5 2 chunks +79 lines, -29 lines 0 comments Download
M src/pkg/runtime/sys_linux_386.s View 1 1 chunk +0 lines, -3 lines 0 comments Download
M src/pkg/runtime/sys_linux_amd64.s View 1 1 chunk +0 lines, -3 lines 0 comments Download
M src/pkg/runtime/sys_linux_arm.s View 1 1 chunk +0 lines, -3 lines 0 comments Download
M src/pkg/runtime/thread_plan9.c View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/syscall/mkerrors.sh View 1 2 3 4 5 4 chunks +54 lines, -5 lines 0 comments Download
M src/pkg/syscall/syscall_bsd.go View 1 2 chunks +6 lines, -6 lines 0 comments Download
M src/pkg/syscall/syscall_darwin.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/syscall/syscall_linux.go View 1 2 3 4 2 chunks +5 lines, -5 lines 0 comments Download
M src/pkg/syscall/syscall_unix.go View 1 2 3 4 1 chunk +16 lines, -0 lines 0 comments Download
M src/pkg/syscall/zerrors_darwin_386.go View 1 2 3 4 5 10 chunks +85 lines, -46 lines 0 comments Download
M src/pkg/syscall/zerrors_darwin_amd64.go View 1 5 3 chunks +71 lines, -32 lines 0 comments Download
M src/pkg/syscall/zerrors_linux_386.go View 1 2 3 4 5 8 chunks +79 lines, -39 lines 0 comments Download
M src/pkg/syscall/zerrors_linux_amd64.go View 1 2 3 4 5 8 chunks +79 lines, -39 lines 0 comments Download
M src/pkg/syscall/zsyscall_freebsd_386.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/syscall/zsyscall_freebsd_amd64.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/syscall/zsyscall_linux_386.go View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/syscall/zsyscall_linux_amd64.go View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/syscall/zsyscall_linux_arm.go View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/syscall/zsysnum_linux_386.go View 1 2 3 4 1 chunk +0 lines, -6 lines 0 comments Download
M src/pkg/syscall/zsysnum_linux_amd64.go View 1 2 3 4 1 chunk +0 lines, -6 lines 0 comments Download

Messages

Total messages: 24
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 9 months ago (2012-02-08 23:13:41 UTC) #1
rsc
This touches a lot of files, but almost all trivially. Don't worry about the large ...
12 years, 9 months ago (2012-02-08 23:14:41 UTC) #2
r2
doc/go1 updates too please
12 years, 9 months ago (2012-02-09 00:07:16 UTC) #3
r
i'm happy with it staying a separate package but could be talked into merging it ...
12 years, 9 months ago (2012-02-09 00:11:56 UTC) #4
dsymonds
http://codereview.appspot.com/3749041/diff/4007/src/pkg/os/signal/signal.go File src/pkg/os/signal/signal.go (right): http://codereview.appspot.com/3749041/diff/4007/src/pkg/os/signal/signal.go#newcode17 src/pkg/os/signal/signal.go:17: l []handler I assume "l" means "list", but it's ...
12 years, 9 months ago (2012-02-09 00:12:46 UTC) #5
bradfitz
http://codereview.appspot.com/3749041/diff/4007/src/pkg/os/exec.go File src/pkg/os/exec.go (right): http://codereview.appspot.com/3749041/diff/4007/src/pkg/os/exec.go#newcode52 src/pkg/os/exec.go:52: type Signal interface { On 2012/02/09 00:11:57, r wrote: ...
12 years, 9 months ago (2012-02-09 00:23:35 UTC) #6
iant
http://codereview.appspot.com/3749041/diff/4007/src/pkg/os/exec.go File src/pkg/os/exec.go (right): http://codereview.appspot.com/3749041/diff/4007/src/pkg/os/exec.go#newcode59 src/pkg/os/exec.go:59: SIGINT Signal = syscall.SIGINT On 2012/02/09 00:23:35, bradfitz wrote: ...
12 years, 9 months ago (2012-02-09 01:20:58 UTC) #7
rsc
On Wed, Feb 8, 2012 at 20:20, <iant@golang.org> wrote: > runtime·sigignore(int32, Siginfo*, void*, G*) > ...
12 years, 9 months ago (2012-02-09 03:08:50 UTC) #8
borman
This solution does not address the issue of the static runtime·sigtab table and its use. ...
12 years, 9 months ago (2012-02-09 16:43:27 UTC) #9
rsc
On Thu, Feb 9, 2012 at 11:43, <borman@google.com> wrote: > This solution does not address ...
12 years, 9 months ago (2012-02-09 18:10:17 UTC) #10
borman
This brings up an issue with Unix signals. All signals can be interrupts (excepting SIGKILL) ...
12 years, 9 months ago (2012-02-09 20:20:02 UTC) #11
rsc
On Thu, Feb 9, 2012 at 15:20, Paul Borman <borman@google.com> wrote: > This brings up ...
12 years, 9 months ago (2012-02-09 20:49:53 UTC) #12
iant2
Russ Cox <rsc@golang.org> writes: > Do you happen to know how to distinguish > signals ...
12 years, 9 months ago (2012-02-09 21:41:57 UTC) #13
borman
In linux you can use the si_code in the siginfo_t structure passed to your handler ...
12 years, 9 months ago (2012-02-09 21:49:13 UTC) #14
rsc1
http://codereview.appspot.com/3749041/diff/4007/src/pkg/os/exec.go File src/pkg/os/exec.go (right): http://codereview.appspot.com/3749041/diff/4007/src/pkg/os/exec.go#newcode52 src/pkg/os/exec.go:52: type Signal interface { On 2012/02/09 00:23:35, bradfitz wrote: ...
12 years, 9 months ago (2012-02-10 23:08:44 UTC) #15
rsc
Hello r@golang.org, dsymonds@golang.org, bradfitz@golang.org, iant@golang.org, borman@google.com (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 9 months ago (2012-02-10 23:14:07 UTC) #16
rsc
PTAL I changed the code to handle an arbitrary number of signals and to distinguish ...
12 years, 9 months ago (2012-02-10 23:18:03 UTC) #17
iant
LGTM Looks you can get rid of the restart parameter of runtime·setsig. http://codereview.appspot.com/3749041/diff/2056/src/pkg/os/exec_posix.go File src/pkg/os/exec_posix.go ...
12 years, 9 months ago (2012-02-11 01:47:29 UTC) #18
dsymonds
LGTM http://codereview.appspot.com/3749041/diff/2056/src/pkg/os/signal/signal.go File src/pkg/os/signal/signal.go (right): http://codereview.appspot.com/3749041/diff/2056/src/pkg/os/signal/signal.go#newcode42 src/pkg/os/signal/signal.go:42: if len(sig) == 0 { I was imagining ...
12 years, 9 months ago (2012-02-11 02:10:28 UTC) #19
rsc
(Not uploaded yet.) http://codereview.appspot.com/3749041/diff/2056/src/pkg/os/exec_posix.go File src/pkg/os/exec_posix.go (right): http://codereview.appspot.com/3749041/diff/2056/src/pkg/os/exec_posix.go#newcode42 src/pkg/os/exec_posix.go:42: return p.Signal(syscall.SIGKILL) On 2012/02/11 01:47:29, iant ...
12 years, 9 months ago (2012-02-13 17:03:26 UTC) #20
rsc
On Fri, Feb 10, 2012 at 20:47, <iant@golang.org> wrote: > Looks you can get rid ...
12 years, 9 months ago (2012-02-13 17:09:57 UTC) #21
borman
http://codereview.appspot.com/3749041/diff/2056/src/pkg/os/signal/signal.go File src/pkg/os/signal/signal.go (right): http://codereview.appspot.com/3749041/diff/2056/src/pkg/os/signal/signal.go#newcode64 src/pkg/os/signal/signal.go:64: default: I almost feel like there should be a ...
12 years, 9 months ago (2012-02-13 17:24:14 UTC) #22
rsc
http://codereview.appspot.com/3749041/diff/2056/src/pkg/os/signal/signal.go File src/pkg/os/signal/signal.go (right): http://codereview.appspot.com/3749041/diff/2056/src/pkg/os/signal/signal.go#newcode64 src/pkg/os/signal/signal.go:64: default: On 2012/02/13 17:24:14, borman wrote: > I almost ...
12 years, 9 months ago (2012-02-13 17:26:56 UTC) #23
rsc
12 years, 9 months ago (2012-02-13 18:52:44 UTC) #24
*** Submitted as http://code.google.com/p/go/source/detail?r=daf22f371d51 ***

os/signal: selective signal handling

Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only.  Also, signals
go to everyone who asks, not just one client.

This could plausibly move into package os now
that there are no magic side effects as a result
of the import.

Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)

Tested on darwin,linux 386,amd64.

Fixes issue 1266.

R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
http://codereview.appspot.com/3749041
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b