mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
Update command.go
This commit is contained in:
parent
de76854134
commit
5c58f7bf02
1 changed files with 3 additions and 4 deletions
|
@ -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)
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue