Tor should not close stdin on child processes.
The lack of PTs having a reliable way to detect if tor is dead reared it's ugly head again in the form of legacy/trac#15434 (moved). There aren't that many good ways to detect if a parent has died, beyond checking if stdin is still open (legacy/trac#10047 (moved) says stdout, however stdin is better), but tor explicitly closes the child process's stdin.
Since a variant of this has been working well, I propose that we make it official like thus:
- Add a new enviornment variable of the form
TOR_PT_EXIT_ON_STDIN_CLOSE=1, indicating that Tor will not close the stdin.
- PTs SHOULD terminate as if they have received a SIGTERM, on stdin being closed if the environment variable is set.
- All new tor versions will naturally set said env. var, and setup the pt plugin stdin correctly.
This does mean that Bridges will consume one extra file descriptor per
ServerTransportPlugin line in the torrc, but I view this as acceptable given the fact that this will bring some much needed sanity to our cleanup process.