Quit sends the app's process a SIGINT, and waits up to 5 seconds for it to exit, returning an error if it doesn't.
()
| 531 | // Quit sends the app's process a SIGINT, and waits up to 5 seconds for it |
| 532 | // to exit, returning an error if it doesn't. |
| 533 | func (a *Handler) Quit() error { |
| 534 | err := a.process.Signal(os.Interrupt) |
| 535 | if err != nil { |
| 536 | return err |
| 537 | } |
| 538 | |
| 539 | c := make(chan error) |
| 540 | go func() { |
| 541 | _, err := a.process.Wait() |
| 542 | c <- err |
| 543 | }() |
| 544 | select { |
| 545 | case err = <-c: |
| 546 | case <-time.After(5 * time.Second): |
| 547 | // TODO Do we want to SIGKILL here or just leave the app alone? |
| 548 | err = errProcessTookTooLong |
| 549 | } |
| 550 | return err |
| 551 | } |