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

Method Cancel

tools/bash/background.go:181–206  ·  view source on GitHub ↗
(taskID string)

Source from the content-addressed store, hash-verified

179 }
180 done := make(chan struct{})
181 cmd := exec.CommandContext(ctx, argv[0], argv[1:]...)
182 if cwd == "" {
183 cwd = "."
184 }
185 cmd.Dir = cwd
186 prepareProcessGroup(cmd)
187 m.mu.Lock()
188 m.running[taskID] = &RunningTask{
189 Cmd: cmd,
190 Cancel: cancel,
191 Done: done,
192 }
193 m.mu.Unlock()
194 go m.runTask(ctx, task, cmd, cancel, done, timeoutValue, hasTimeout)
195 return task, nil
196}
197
198func (m *BackgroundManager) Cancel(taskID string) bool {
199 m.mu.Lock()
200 task := m.tasks[taskID]
201 running := m.running[taskID]
202 if task == nil || task.Status != "running" || running == nil {
203 m.mu.Unlock()
204 return false
205 }
206 task.Status = "cancelled"
207 task.EndTime = float64Ptr(nowSeconds())
208 m.mu.Unlock()
209 terminateProcessTree(running.Cmd)

Callers

nothing calls this directly

Calls 3

float64PtrFunction · 0.85
terminateProcessTreeFunction · 0.85
nowSecondsFunction · 0.70

Tested by

no test coverage detected