23 lines
1.2 KiB
C
23 lines
1.2 KiB
C
// calogProc.h -- calog subprocess library: run a child process, capture its output.
|
|
//
|
|
// procRun(argv: list(string) [, opts: map]) -> map{ exit: int, stdout: string, stderr: string }
|
|
// Spawn argv[0] with the given arguments, wait for it, and return its exit code (or the
|
|
// negative signal number if it was killed) plus its captured stdout/stderr (binary-safe).
|
|
// opts: { stdin: string (fed to the child), cwd: string (working directory), env: map
|
|
// (string->string; REPLACES the environment -- omit to inherit the parent's) }.
|
|
//
|
|
// The child is started with posix_spawn (NOT fork -- calog runs many pthreads, and fork in a
|
|
// multithreaded process is a well-known hazard). The native is inline and blocks the calling
|
|
// context's own thread until the child exits, feeding stdin while draining stdout/stderr through a
|
|
// single poll loop so a large transfer cannot deadlock. Subprocess spawning is POSIX-only; on
|
|
// Windows the native returns an "unsupported" error rather than a half-working implementation.
|
|
|
|
#ifndef CALOG_PROC_H
|
|
#define CALOG_PROC_H
|
|
|
|
#include "calog.h"
|
|
|
|
// Register the subprocess native on a runtime. Idempotent across runtimes (no shared state).
|
|
int32_t calogProcRegister(CalogT *calog);
|
|
|
|
#endif
|