forked from maxtaco/go-framed-msgpack-rpc
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from keybase/mike/sigpipe
add option to disable SIGPIPE on BSD-like systems
- Loading branch information
Showing
3 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// +build !darwin | ||
|
||
package rpc | ||
|
||
import "net" | ||
|
||
func DisableSigPipe(c net.Conn) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//+build darwin | ||
|
||
package rpc | ||
|
||
import ( | ||
"net" | ||
"reflect" | ||
"syscall" | ||
) | ||
|
||
func DisableSigPipe(c net.Conn) error { | ||
// Disable SIGPIPE on this connection since we currently need to do this manually for iOS | ||
// to prevent the signal from crashing iOS apps. | ||
// See: https://github.com/golang/go/issues/17393 | ||
fd := int(reflect.ValueOf(c).Elem().FieldByName("fd").Elem().FieldByName("sysfd").Int()) | ||
return syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_NOSIGPIPE, 1) | ||
} |