open-vault/command/commands_nonwindows.go
Hamid Ghaf 27bb03bbc0
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

30 lines
539 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build !windows
package command
import (
"os"
"os/signal"
"syscall"
)
// MakeSigUSR2Ch returns a channel that can be used for SIGUSR2
// goroutine logging. This channel will send a message for every
// SIGUSR2 received.
func MakeSigUSR2Ch() chan struct{} {
resultCh := make(chan struct{})
signalCh := make(chan os.Signal, 4)
signal.Notify(signalCh, syscall.SIGUSR2)
go func() {
for {
<-signalCh
resultCh <- struct{}{}
}
}()
return resultCh
}