MCPcopy Index your code
hub / github.com/docker/docker-agent / StopBackgroundJob

Method StopBackgroundJob

pkg/tools/builtin/shell/shell.go:470–486  ·  view source on GitHub ↗
(_ context.Context, params StopBackgroundJobArgs)

Source from the content-addressed store, hash-verified

468}
469
470func (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

Callers

nothing calls this directly

Calls 5

ResultErrorFunction · 0.92
ResultSuccessFunction · 0.92
statusToStringFunction · 0.85
LoadMethod · 0.80
killFunction · 0.70

Tested by

no test coverage detected