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

Side by Side Diff: src/cmd/go/signal.go

Issue 6903061: code review 6903061: cmd/go: handle os signals (Closed)
Patch Set: diff -r b1822aac85b7 https://go.googlecode.com/hg/ Created 12 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/cmd/go/run.go ('k') | src/cmd/go/signal_notunix.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package main
6
7 import (
8 "os"
9 "os/signal"
10 "sync"
11 )
12
13 // interrupted is closed, if go process is interrupted.
14 var interrupted = make(chan struct{})
15
16 func closeInterrupted() {
17 close(interrupted)
18 }
19
20 var onceCloseInterrupted sync.Once
21
22 // processSignals setups signal handler.
23 func processSignals() {
24 sig := make(chan os.Signal)
25 signal.Notify(sig, signalsToIgnore...)
26 go func() {
27 for _ = range sig {
28 onceCloseInterrupted.Do(closeInterrupted)
dave_cheney.net 2012/12/14 00:16:45 I'm sorry to harp on this. I don't think the sync.
29 return
30 }
31 }()
32 }
33
34 var onceProcessSignals sync.Once
35
36 // startSigHandlers start signal handlers.
37 func startSigHandlers() {
38 onceProcessSignals.Do(processSignals)
39 }
OLDNEW
« no previous file with comments | « src/cmd/go/run.go ('k') | src/cmd/go/signal_notunix.go » ('j') | no next file with comments »

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