cosmopolitan
cosmopolitan copied to clipboard
Fix stderr being improperly closed during daemonization
This may happen when ProgramLogPath is used after a file descriptor is already used by an earlier call (for example, to open an SQLite file).
@jart, this is a simple patch, but I'd appreciate your review. This should fix the scenario when ProgramLogPath is set some time after another file descriptor is open (thus occupying slot 2) and daemonization is requested, so that when ProgramLogPath is used, it will close and open it to redirect the log file.
I also removed the IsServerFd
, as none should be allocated yet before Listen
is done.