2023-02-02 17:15:17 -08:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2021-09-27 16:24:00 -04:00
|
|
|
//go:build !windows
|
2020-02-12 13:53:27 -05:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|