Return a file descriptor to write directly to the Redis log with the * write(2) syscall, that can be used in critical sections of the code * where the rest of Redis can't be trusted (for example during the memory * test) or when an API call requires a raw fd. * * Close it with closeDirectLogFiledes(). */
| 1527 | * |
| 1528 | * Close it with closeDirectLogFiledes(). */ |
| 1529 | int openDirectLogFiledes(void) { |
| 1530 | int log_to_stdout = server.logfile[0] == '\0'; |
| 1531 | int fd = log_to_stdout ? |
| 1532 | STDOUT_FILENO : |
| 1533 | open(server.logfile, O_APPEND|O_CREAT|O_WRONLY, 0644); |
| 1534 | return fd; |
| 1535 | } |
| 1536 | |
| 1537 | /* Used to close what closeDirectLogFiledes() returns. */ |
| 1538 | void closeDirectLogFiledes(int fd) { |
no outgoing calls
no test coverage detected