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

2.0 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_spawn function go infra 1.0.0 impure func ProcessSpawn(command string, dir string, env []string, shell string) (*ProcessHandle, error) Lanza un subproceso usando el shell indicado. Si shell esta vacio usa 'sh'. Comandos con newlines se tratan como scripts multilinea (se escriben a un archivo temporal). Configura un process group propio (Setpgid) para poder matar todos los hijos con ProcessKill. Captura stdout y stderr via pipes.
process
subprocess
spawn
exec
shell
infra
process_handle_go_infra
process_handle_go_infra
false error_go_core
fmt
os
os/exec
strings
syscall
time
name desc
command comando shell a ejecutar; si contiene newlines se trata como script multilinea
name desc
dir directorio de trabajo del proceso hijo; vacio hereda el del proceso padre
name desc
env variables de entorno en formato KEY=VALUE; nil hereda el entorno del proceso padre
name desc
shell interprete shell a usar (sh, bash, zsh); vacio usa 'sh'
handle del proceso lanzado con Cmd, Pid, StartTime, Dir y los pipes de I/O true
spawn and wait echo
spawn with timeout kills
spawn with env
spawn script
spawn with working dir
kill process
functions/infra/process_spawn_test.go functions/infra/process_spawn.go

Ejemplo

h, err := ProcessSpawn("echo hello", "", nil, "")
if err != nil {
    log.Fatal(err)
}
res, err := ProcessWait(h, 10)
fmt.Println(res.Stdout) // "hello\n"

Notas

Funcion impura: hace I/O (crea archivo temporal para scripts, lanza proceso). El process group (Setpgid=true) permite a ProcessKill enviar senales al grupo completo con -Pid, afectando a todos los hijos del proceso lanzado. Para scripts multilinea el archivo temporal queda en el directorio temporal del OS y no se limpia automaticamente.