Files
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.8 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_wait function go infra 1.0.0 impure func ProcessWait(handle *ProcessHandle, timeoutSec int) (ProcessResult, error) Espera a que un subproceso termine y recopila su salida. Lee stdout y stderr completos en goroutines para evitar deadlocks en pipes. Si timeoutSec > 0 y el proceso no termina en ese tiempo, llama a ProcessKill y marca el resultado con Killed=true. Retorna el exit code, salida completa y duracion total.
process
subprocess
wait
timeout
exec
infra
process_kill_go_infra
process_handle_go_infra
process_result_go_infra
process_result_go_infra
false error_go_core
fmt
io
time
name desc
handle handle del proceso lanzado por ProcessSpawn
name desc
timeoutSec segundos maximos de espera; 0 o negativo espera indefinidamente
resultado con exit code, stdout, stderr, duracion en ms y flag de killed true
spawn and wait echo
spawn with timeout kills
spawn with env
spawn script
spawn with working dir
functions/infra/process_spawn_test.go functions/infra/process_wait.go

Ejemplo

h, err := ProcessSpawn("sleep 60", "", nil, "")
if err != nil {
    log.Fatal(err)
}
res, err := ProcessWait(h, 5) // timeout de 5 segundos
if res.Killed {
    fmt.Println("proceso terminado por timeout")
}

Notas

Funcion impura: bloquea esperando I/O y posiblemente llama a ProcessKill. Lee stdout y stderr en goroutines separadas antes de llamar a cmd.Wait() para evitar el deadlock clasico donde cmd.Wait() bloquea porque los pipes estan llenos y nadie los lee. El exit code -1 indica que ProcessState no estaba disponible (proceso matado antes de registrar estado).