Processes, environment and signals
A Rust program is one process among many. This chapter covers the edges: the environment it inherits, the commands it starts, the pipes it writes into, the signal the terminal sends it.
Most of it is std::process, and most of it has a failure mode worth knowing about before you
ship.
Articles
Section titled “Articles”- How to read environment variablesenv::var, and the error it returns
- How to set an environment variable for a child processCommand::env, and what the child inherits
- How to run an external command and read its outputCommand::output, and the exit status
- How to check whether a command existsPATH lookup, and the spawn that fails instead
- How to pipe data between processesStdio::piped, and the deadlock if you read in order
- How to run a command with a timeoutwait_timeout, and killing the child properly
- How to handle Ctrl+C gracefullycatching SIGINT and cleaning up
- How to run a task on a timerinterval versus sleep, and the drift