mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 15:38:22 +00:00
Fix stderr being improperly closed during daemonization (#513)
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).
This commit is contained in:
parent
5f552338d6
commit
449fb2fb59
1 changed files with 2 additions and 3 deletions
|
@ -7320,12 +7320,11 @@ void RedBean(int argc, char *argv[]) {
|
|||
-1, 0)));
|
||||
if (daemonize) {
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
if (!IsServerFd(i)) {
|
||||
close(i);
|
||||
}
|
||||
close(i);
|
||||
}
|
||||
open("/dev/null", O_RDONLY);
|
||||
open("/dev/null", O_WRONLY);
|
||||
open("/dev/null", O_WRONLY);
|
||||
}
|
||||
zpath = GetProgramExecutableName();
|
||||
CHECK_NE(-1, (zfd = open(zpath, O_RDONLY)));
|
||||
|
|
Loading…
Add table
Reference in a new issue