pub fn getoutputfile(cmd: &str, eptr: Option<&mut usize>) -> Option<String>Expand description
Port of getoutputfile() from Src/exec.c:4910 — C decl getoutputfile(char *cmd, char **eptr).
=(cmd) process substitution.
Substitutes the cmd’s stdout into a temp file, returns the
filename. Optimised path: =(<<<heredoc-str) writes the
heredoc body directly without a fork.
(a) addfilelist(nam, 0) (c:4960) wired via JOBTAB[thisjob]
so the temp file gets cleaned at job exit.
(b) waitforpid Rust takes 1 arg pid, C takes (pid, full).
Behavior matches the full=0 case anyway.
(c) This is a REAL fork (zfork below), not a collapsed one, so the
child gets the full entersubsh(ESUB_PGRP|ESUB_NOMONITOR, NULL)
(c:4986) via the canonical port at exec.rs:4329 — no in-process
SubshStateGuard substitute is needed or wanted here.
(d) execode is now ported (exec.rs:6047) — the body still
re-feeds through fusevm for cache coherence with execstring.
(e) The child ends with _realexit() (c:4991) after flushing
Rust’s in-process stdout buffer.
(f) The TMPSUFFIX link() block (c:4951-4958) hard-links the temp
file to nam + $TMPSUFFIX; both names are registered for
cleanup.