<p dir="auto">I use go version go1.5.1 darwin/amd64.</p>
<p dir="auto">I write a simple http server like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="package main

import (
        &quot;log&quot;
        &quot;net/http&quot;
        &quot;os&quot;
        &quot;os/signal&quot;
)

func main() {
        c := make(chan os.Signal, 1)
        signal.Notify(c)
        go func() {
                for s := range c {
                        log.Println(&quot;recv signal: &quot;, s.String())
                }
        }()

        http.HandleFunc(&quot;/hello&quot;, func(rw http.ResponseWriter, r *http.Request) {
                resp, _ := http.Get(&quot;http://www.baidu.com&quot;)
                if resp != nil &amp;&amp; resp.Body != nil {
                        resp.Body.Close()
                }
                http.Error(rw, &quot;ok&quot;, http.StatusOK)
        })
        log.Fatal(http.ListenAndServe(&quot;:8888&quot;, nil))
}"><pre class="notranslate"><code class="notranslate">package main

import (
        "log"
        "net/http"
        "os"
        "os/signal"
)

func main() {
        c := make(chan os.Signal, 1)
        signal.Notify(c)
        go func() {
                for s := range c {
                        log.Println("recv signal: ", s.String())
                }
        }()

        http.HandleFunc("/hello", func(rw http.ResponseWriter, r *http.Request) {
                resp, _ := http.Get("http://www.baidu.com")
                if resp != nil &amp;&amp; resp.Body != nil {
                        resp.Body.Close()
                }
                http.Error(rw, "ok", http.StatusOK)
        })
        log.Fatal(http.ListenAndServe(":8888", nil))
}
</code></pre></div>
<p dir="auto">Then, If I curl <a href="http://127.0.0.1:8888/hello" rel="nofollow">http://127.0.0.1:8888/hello</a> and then press Ctrl-C very quickly, the server will receive "broken pipe" signal. And if server receive many broken pipe signal, the process will exit.</p>
<p dir="auto">Back in <a href="https://go.googlesource.com/go/+/f7d3eb9db97a65a43b8d6b8bf42b8698fe4468ee" rel="nofollow">https://go.googlesource.com/go/+/f7d3eb9db97a65a43b8d6b8bf42b8698fe4468ee</a> we added code so that if we saw 10 EPIPE failures in a row on the same file descriptor, we would exit the program.  Today we exit the program by raising a SIGPIPE signal, but we still wait for 10 failures.  That leads to issues like <a href="https://golang.org/issue/11839" rel="nofollow">https://golang.org/issue/11839</a> and workarounds like <a href="https://golang.org/cl/12571" rel="nofollow">https://golang.org/cl/12571</a>.</p>
<p dir="auto">Now that we have the os/signal package, Go programs have the mechanisms they need to control this.  I propose that we change the Go runtime to not handle SIGPIPE by default.  If os/signal.Notify is used for SIGPIPE, that only at that point should we add a handler for SIGPIPE.  Then we should remove the EPIPE handling from the os package, and treat it like any other error.</p>