Skip to content

Commit

Permalink
Fix signal handling
Browse files Browse the repository at this point in the history
  • Loading branch information
awnumar committed Mar 11, 2020
1 parent a477fe1 commit 2fc8c81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/socketkey/socketkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func SocketKey(size int) {
memguard.CatchSignal(func(s os.Signal) {
fmt.Println("Received signal:", s.String())
listener.Close()
})
}, os.Interrupt, os.Kill)

// Purge the session before returning.
defer memguard.Purge()
Expand Down
7 changes: 7 additions & 0 deletions examples/socketkey/socketkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ import "testing"
func TestSocketKey(t *testing.T) {
SocketKey(4096)
}

func BenchmarkSocketKey32(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
SocketKey(32)
}
}

0 comments on commit 2fc8c81

Please sign in to comment.