741fdcee24
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>
1.6 KiB
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. |
|
|
false | error_go_core |
|
|
nil si el proceso fue terminado correctamente; error si la senal no pudo entregarse | true |
|
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.