Files
fn_registry/functions/infra/process_kill.md
T
egutierrez 741fdcee24 feat: add process manager and execution store types (0007b, 0007c)
Process spawn/wait/kill functions for subprocess management with output
capture, timeout, and process group cleanup. DagRun and DagStepResult
types for SQLite execution persistence.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 13:05:13 +02:00

1.6 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path
process_kill function go infra 1.0.0 impure func ProcessKill(handle *ProcessHandle, graceSec int) error Termina un subproceso enviando SIGTERM al process group. Espera hasta graceSec segundos a que el proceso muera voluntariamente. Si sigue vivo, envia SIGKILL. Retorna error solo si la senal no pudo entregarse.
process
subprocess
kill
signal
sigterm
sigkill
infra
process_handle_go_infra
false error_go_core
fmt
syscall
time
name desc
handle handle del proceso lanzado por ProcessSpawn
name desc
graceSec segundos de gracia entre SIGTERM y SIGKILL; 0 envia SIGKILL inmediatamente
nil si el proceso fue terminado correctamente; error si la senal no pudo entregarse true
kill process
functions/infra/process_spawn_test.go functions/infra/process_kill.go

Ejemplo

h, err := ProcessSpawn("sleep 300", "", nil, "")
if err != nil {
    log.Fatal(err)
}
// Dar 3 segundos de gracia antes de SIGKILL
if err := ProcessKill(h, 3); err != nil {
    log.Printf("kill failed: %v", err)
}

Notas

Funcion impura: envia senales al sistema operativo. Usa -handle.Pid (negativo) para direccionar el process group completo, matando tanto al proceso principal como a sus hijos. ESRCH se ignora porque significa que el proceso ya murio, lo cual es el objetivo deseado. Comprueba si el proceso sigue vivo con signal 0 (kill -0) cada 100ms durante el grace period.