func (e SignalError) Error() string {
	return fmt.Sprintf("received signal %s", e.Signal)
}
Error implements the error interface.
package run
import (
	"context"
	"fmt"
	"os"
	"os/signal"
)
func SignalHandler(ctx context.Context, signals ...os.Signal) (execute func() error, interrupt func(error)) {
	ctx, cancel := context.WithCancel(ctx)
	return func() error {
			c := make(chan os.Signal, 1)
			signal.Notify(c, signals...)
			defer signal.Stop(c)
			select {
			case sig := <-c:
				return SignalError{Signal: sig}
			case <-ctx.Done():
				return ctx.Err()
			}
		}, func(error) {
			cancel()
		}
}
type SignalError struct {
	Signal os.Signal
}