Update command.go

This commit is contained in:
Dean Eigenmann 2024-06-20 09:37:19 +02:00 committed by GitHub
parent de76854134
commit 5c58f7bf02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -141,7 +141,7 @@ type Command struct {
// PersistentPostRunE: PersistentPostRun but returns an error.
PersistentPostRunE func(cmd *Command, args []string) error
// OnKillRun: run if a commands execution is exited
OnKillRun func(cmd *Command, args []string)
OnKillRun func(cmd *Command, args []string, os.Signal)
// groups for subcommands
commandgroups []*Group
@ -939,15 +939,14 @@ func (c *Command) execute(a []string) (err error) {
signal.Notify(
sigchan,
syscall.SIGINT,
syscall.SIGKILL,
syscall.SIGTERM,
syscall.SIGQUIT,
)
go func() {
_ = <-sigchan
s := <-sigchan
c.OnKillRun(c, argWoFlags)
c.OnKillRun(c, argWoFlags, s)
}()
}