MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / WaitFor

Method WaitFor

tools/bash/background.go:208–237  ·  view source on GitHub ↗
(taskID string, timeout time.Duration)

Source from the content-addressed store, hash-verified

206 task.Status = "cancelled"
207 task.EndTime = float64Ptr(nowSeconds())
208 m.mu.Unlock()
209 terminateProcessTree(running.Cmd)
210 running.Cancel()
211 select {
212 case <-running.Done:
213 case <-time.After(5 * time.Second):
214 if running.Cmd.Process != nil {
215 _ = running.Cmd.Process.Kill()
216 }
217 }
218
219 m.mu.Lock()
220 delete(m.running, taskID)
221 m.mu.Unlock()
222 return true
223}
224
225func (m *BackgroundManager) WaitFor(taskID string, timeout time.Duration) *BackgroundTask {
226 m.mu.Lock()
227 task := m.tasks[taskID]
228 if task == nil {
229 m.mu.Unlock()
230 return nil
231 }
232 if task.Status != "running" {
233 m.mu.Unlock()
234 return task
235 }
236 running := m.running[taskID]
237 m.mu.Unlock()
238 if running == nil {
239 return task
240 }

Calls

no outgoing calls