(_ context.Context, params StopBackgroundJobArgs)
| 468 | } |
| 469 | |
| 470 | func (h *shellHandler) StopBackgroundJob(_ context.Context, params StopBackgroundJobArgs) (*tools.ToolCallResult, error) { |
| 471 | job, exists := h.jobs.Load(params.JobID) |
| 472 | if !exists { |
| 473 | return tools.ResultError("Job not found: " + params.JobID), nil |
| 474 | } |
| 475 | |
| 476 | if !job.status.CompareAndSwap(statusRunning, statusStopped) { |
| 477 | currentStatus := job.status.Load() |
| 478 | return tools.ResultError(fmt.Sprintf("Job %s is not running (current status: %s)", params.JobID, statusToString(currentStatus))), nil |
| 479 | } |
| 480 | |
| 481 | if err := kill(job.process, job.processGroup); err != nil { |
| 482 | return tools.ResultError(fmt.Sprintf("Job %s marked as stopped, but error killing process: %s", params.JobID, err)), nil |
| 483 | } |
| 484 | |
| 485 | return tools.ResultSuccess(fmt.Sprintf("Job %s stopped successfully", params.JobID)), nil |
| 486 | } |
| 487 | |
| 488 | // reapSpawnedChild terminates a child that we've started but decided not |
| 489 | // to run (e.g. follow-up setup failed) and waits for it so we don't leak a |
nothing calls this directly
no test coverage detected