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(). */
| 1635 | * |
| 1636 | * Close it with closeDirectLogFiledes(). */ |
| 1637 | int openDirectLogFiledes(void) { |
| 1638 | int log_to_stdout = g_pserver->logfile[0] == '\0'; |
| 1639 | int fd = log_to_stdout ? |
| 1640 | STDOUT_FILENO : |
| 1641 | open(g_pserver->logfile, O_APPEND|O_CREAT|O_WRONLY, 0644); |
| 1642 | return fd; |
| 1643 | } |
| 1644 | |
| 1645 | /* Used to close what closeDirectLogFiledes() returns. */ |
| 1646 | void closeDirectLogFiledes(int fd) { |
no outgoing calls
no test coverage detected