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: PersistentPostRun but returns an error.
|
||||||
PersistentPostRunE func(cmd *Command, args []string) error
|
PersistentPostRunE func(cmd *Command, args []string) error
|
||||||
// OnKillRun: run if a commands execution is exited
|
// 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
|
// groups for subcommands
|
||||||
commandgroups []*Group
|
commandgroups []*Group
|
||||||
|
@ -939,15 +939,14 @@ func (c *Command) execute(a []string) (err error) {
|
||||||
signal.Notify(
|
signal.Notify(
|
||||||
sigchan,
|
sigchan,
|
||||||
syscall.SIGINT,
|
syscall.SIGINT,
|
||||||
syscall.SIGKILL,
|
|
||||||
syscall.SIGTERM,
|
syscall.SIGTERM,
|
||||||
syscall.SIGQUIT,
|
syscall.SIGQUIT,
|
||||||
)
|
)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
_ = <-sigchan
|
s := <-sigchan
|
||||||
|
|
||||||
c.OnKillRun(c, argWoFlags)
|
c.OnKillRun(c, argWoFlags, s)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue