Skip to main content

scratch_file

Function scratch_file 

Source
pub fn scratch_file(environment: &[(OsString, OsString)]) -> Result<File>
Expand description

What: An anonymous file (no name in the directory) in the per-user scratch directory of environment, open for reading and writing. Why: Child output goes to a file so that no reader thread can outlive a stopped child; the file has no name from the start (an unnamed temporary file where the system has them, otherwise a name removed at once), so a killed process leaves nothing to collect, and the system temporary directory is never used.

In TS you’d write (pseudocode):

const handle = await open(await prepareUserScratch(env), 'wx+'); // unlinked at once