Stop stops the guacd process. It signals the process via context cancellation and waits for the existing wait() goroutine to finish, avoiding a double Wait race.
()
| 119 | // Stop stops the guacd process. It signals the process via context cancellation |
| 120 | // and waits for the existing wait() goroutine to finish, avoiding a double Wait race. |
| 121 | func (p *Process) Stop() { |
| 122 | p.mu.Lock() |
| 123 | if p.cancel != nil { |
| 124 | p.cancel() |
| 125 | p.cancel = nil |
| 126 | } |
| 127 | p.mu.Unlock() |
| 128 | |
| 129 | // Wait for the existing wait() goroutine to observe the exit. |
| 130 | select { |
| 131 | case <-p.done: |
| 132 | case <-time.After(3 * time.Second): |
| 133 | // Force kill if context cancellation wasn't enough. |
| 134 | p.mu.Lock() |
| 135 | if p.cmd != nil && p.cmd.Process != nil { |
| 136 | _ = p.cmd.Process.Kill() |
| 137 | } |
| 138 | p.mu.Unlock() |
| 139 | <-p.done |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | // Running returns true if guacd is still running. |
| 144 | func (p *Process) Running() bool { |
no outgoing calls
no test coverage detected