Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
Ignore SIGPIPE for systemd, fixes #13.
Browse files Browse the repository at this point in the history
  • Loading branch information
ymmt2005 committed Mar 1, 2017
1 parent 5a2c7f2 commit e4aaf7a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Changed
- Fix `NewEnvironment` documentation.
- Ignore SIGPIPE for systemd (#13).

## [1.4.0] - 2016-09-10
### Added
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Commands using this framework implement these external specifications:

On Windows, this is not implemented.

* `SIGPIPE`

SIGPIPE is completely ignored. See [#13](https://github.com/cybozu-go/cmd/issues/13) for details.

### Environment variables

* `REQUEST_ID_HEADER`
Expand Down
1 change: 1 addition & 0 deletions default.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var (
func init() {
defaultEnv = NewEnvironment(context.Background())
handleSignal(defaultEnv)
ignoreSigPipe()
}

// Stop just declares no further Go will be called.
Expand Down
12 changes: 12 additions & 0 deletions sigpipe.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build !windows

package cmd

import (
"os/signal"
"syscall"
)

func ignoreSigPipe() {
signal.Ignore(syscall.SIGPIPE)
}
3 changes: 3 additions & 0 deletions sigpipe_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package cmd

func ignoreSigPipe() {}

0 comments on commit e4aaf7a

Please sign in to comment.